#!/usr/local/bin/python3
# coding: utf-8
import shutil
import os
import sys
import tempfile
import copy
import re
import hashlib
import tempfile
from .program import *
from .process import *
from subprocess import *
from optparse import *
from time import gmtime, strftime
from argparse import *

log = []

SAMPLE_RATE = 44100

"""Command-line stuff.
"""
file_list_default = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
parser = ArgumentParser()
parser.add_argument("files", nargs="+", help="The file or list of files to be processed")

parser.add_argument("-l", "--file-list", default=file_list_default, help="save a list the files generated by this session")
parser.add_argument("-k", "--keep-intermediate-files", default=False, help="keep the files created between processes. useful if you want to pick out audio that was created at each step. keep in mind that this generates a large amount of data!")
options = parser.parse_args()
#print(options)
print(options)
input_files = options.files

class PyCDP:
    def __init__(self):
        # CDP PROGRAMS
        self.programs = ["blur", "filter", "focus", "hilite", "combine", "formants", "morph", "modify", "pitch", "psow", "repitch", "stretch", "texture", "distort", "extend", "grain", "strange", "envel", "housekeep", "sfedit", "sndinfo", "submix", "synth", "pvoc", "pitchinfo", "spec", "specinfo", "reverb"]

        ret = [setattr(self, p,  program(p)) for p in self.programs]

    def run_chain(self, chain):
        input_files = options.files

        """Run a chain of CDP processes provided by a user.
        """
        #tmpdir = tempfile.NamedTempraryFile(delete = False)

        input_files_temp = []

        """ input files
        """
        for input_file in input_files:
            if not os.path.exists(input_file) or input_file is None:
                input_files.remove(input_file)

        """ copy filenames to temp files
        """

        temporary_files = []

        try:
            for input_file in input_files:
                temporary_file = tempfile.NamedTemporaryFile(delete = False, suffix = ".wav")
                print(temporary_file)
                print(temporary_file.name)
                shutil.copy(input_file, temporary_file.name)
                temporary_files.append(temporary_file.name)
        except OSError as e:
            print("sommat {}".format(e.filename))

        """ create list of destination files
        """

        input_files_orig = input_files

        input_files = temporary_files

        output_files = []
        output_file_final = []
        final = []

        """GOGOGOGOGOGOGOGOGOGOGOGO
        """
        try:
            for index, sess in enumerate(chain):
                """Run the session
                """

                print("START {}".format(input_files))
                input_files = sess.queue(input_files)
                print("FIN {}".format(input_files))

                # collect last files
                if index is len(chain):
                    output_files.extend(input_files)
                else:
                    print(("Warning: No output file for input file: %s" % input_files))
        except Exception as e:
            #print("{} {} {}".format(input_files, output_files, index))
            raise

        """Blow away old file if it exists ... this is pretty unlikely.
        """
        for f in output_files[:-1]:
            if os.path.exists(f) and f not in r_orig:
                os.unlink(f)

        """Move output files from temp locations to output directory.
        """
        for output_file in output_files[:-1]:
            if(os.path.file_exists(output_file)):
                m = hashlib.md5()
                m.update(os.path.basename(output_file))

                output_file_final = '/'.join(options.output_dir).join("%s.%s.%s" % (m.hexdigest(), output_file, ".wav"))

                mv = "mv %s %s" % (output_file, output_file_final)

                ret = call(mv)

                if ret:
                    raise ValueError("Could not move %s to %s", output_file, output_file_final)

                final.append(output_file_final)

        """Get rid of the temp folder.
        """
        try:
            for temporary_file in temporary_files:
                shutil.unlink(temporary_file)
        except Exception as e:
            print("tmpfile is already gone?")

        try:
            if options.file_list:
                """Create list of files
                """
                '\n'.join(final)

                """Write list of files
                """
                file_list = open(options.file_list, "w+")
                file_list.write('PYCDP LOG\n=========\n\n'.join(final))
                file_list.write('\n'.join(final))
                file_list.close()
        except Exception as e:
            print(e)

        return final

#
# Initialize our wonderful cdp variable.
#

cdp = PyCDP()

#
# ENVEL     ----------------------------------------
#
"""
    ENVELOPE OPERATION ON AN ENVELOPE-FILE
    reshape
    envtobrk    envtodb

    ENVELOPE OPERATION ON A BRKPNT (TEXT) FILE

    replot
    dbtogain    gaintodb
    brktoenv    dbtoenv
"""

cdp.envel.add_process("create",     "-", "-", 2,    "CREATE AN ENVELOPE.")
cdp.envel.add_process("cyclic",     "-", "-", 4,    "CREATE A SEQUENCE OF REPEATED ENVELOPES, IN A BINARY ENVELOPE FILE.")
cdp.envel.add_process("extract",    "-", "-", 2,    "EXTRACT ENVELOPE FROM AN INPUT SOUNDFILE.")
cdp.envel.add_process("impose",     "-", "-", 4,    "IMPOSE AN ENVELOPE ON AN INPUT SOUNDFILE.")
cdp.envel.add_process("replace",    "-", "-", 4,    "REPLACE THE EXISTING ENVELOPE OF AN INPUT SOUNDFILE WITH A DIFFERENT ENVELOPE.")
cdp.envel.add_process("warp",       "-", "-", 15,   "WARP THE ENVELOPE OF A SOUNDFILE.")
cdp.envel.add_process("tremolo",    "-", "-", 2,    "TREMOLO A SOUND")
cdp.envel.add_process("swell",      "-", "-", None, "CAUSE SOUND TO FADE IN TO AND OUT FROM A PEAK MOMENT")
cdp.envel.add_process("attack",     "-", "-", 4,    "EMPHASIZE THE ATTACK OF A SOUND")
cdp.envel.add_process("pluck",      "M", "M", None, "PLUCK START OF SOUND (MONO FILES ONLY)")
#
# ENVEL DOVETAIL
#
cdp.envel.add_process("dovetail", "-", "-", 2, "DOVETAIL SNDFILE BY ENVELOPING THE START AND END OF IT.")
params = [["infadedur", 0, None, "duration of start-of-file fade-in"],
          ["outfadedur", 0, None, "duration of end-of-file fade-out"],
          ["-t", 0, 2, "seconds (-t0) samples (-t1), or grouped-samples (-t2)"]]

cdp.envel.dovetail.add_mode(2, params, "DOVETAIL MODE 2")

params.append(["intype", 0, 1])
params.append(["outtype", 0, 1])

cdp.envel.dovetail.add_mode(1, params, "DOVETAIL MODE 1")
#
#
#
cdp.envel.add_process("curtail", "-", "-", 6, "CURTAIL SNDFILE BY FADING TO ZERO AT SOME TIME WITHIN IT.")
cdp.envel.add_process("scaled", "-", "-", None, "IMPOSE AN ENVELOPE ON AN INPUT SOUNDFILE, SCALING IT TIMEWISE TO SOUND'S DURATION.")

# HOUSEKEEP ---------------------------------------- 
#
# HOUSEKEEP CHANS
#
cdp.housekeep.add_process("chans", "S", "M", 5, "EXTRACT OR CONVERT CHANNELS OF SOUNDFILE.")
cdp.housekeep.chans.add_mode(4, None, "STEREO TO MONO", "S", "M") # STEREO TO MONO
cdp.housekeep.chans.add_mode(5, None, "MONO TO STEREO", "M", "S") # MONO TO STEREO
#
# HOUSEKEEP EXTRACT
#
cdp.housekeep.add_process("extract", "-", "-", 6, None)
params = [["-g", 0, 1, "level ABOVE which signal accepted"],
          ["-s", 0, None, "length in mS (default 15mS)"],
          ["-b", None, None],
          ["-e", None, None],
          ]
cdp.housekeep.extract.add_mode(3, params, "TOP AND TAIL")

params = [["shift", 0, 1, None]]
cdp.housekeep.extract.add_mode(4, params, "RECTIFY: SHIFT ENTIRE SIGNAL TO ELIMINATE DC DRIFT.")
#
# DISTORT   ----------------------------------------
#
#
# DISTORT PITCH
#
cdp.distort.add_process("pitch", "M", "M", None, "PITCHWARP 'WAVECYCLES' OF SOUND.")
params = [
            ["octvary", 0.001, 8.0, "maximum possible transposition up or down in (fractions of) octaves (Range > 0.0 to 8.0)"],
            ["-c", 0, None,         "mamimum number of 'wavecycles' between the generation of transposition values (Range: > 1, Default: 64)"],
            ["-s", 0, None,         "(integer) number of 'wavecycles' to skip at start of file"]
         ]
cdp.distort.pitch.add_parameters(params)

cdp.distort.add_process("delete", "M", "M", 3, "TIMECONTRACT FILE BY DELETING 'WAVECYCLES'")
params = [
            ["cyclecnt", 2, None],
            ["-s", 0, None, "(integer) number of 'wavecycles' to skip at start of file"]
         ]
cdp.distort.delete.add_mode(1, params)
cdp.distort.delete.add_mode(2, params)
cdp.distort.delete.add_mode(3, params)

#
# EXTEND
#
#
# DRUNK
#
cdp.extend.add_process("drunk", "-", "-", 2, "SPLICE SEGMENTS OF SRCFILE END-TO-END: START-TIMES (IN SRCFILE) OF SEGS,CHOSEN BY 'DRUNKEN-WALK' THROUGH SRCFILE:   IN MODE 2, SRCFILE PLAYS SOBERLY AT HOLDS")
params = [
            ["outdur",  0,      None,   "Total (minimum) duration of output file (secs)"],
            ["locus",   0,      None,   "Time in src around which drunkwalk happens.(secs) CAN MOVE THRO SRC."],
            ["ambitus", 0,      None,   "(half)width of region from within which sound-segments read.(secs)."],
            ["step",    0.002,  None,   "Max length of (random) step between segment-reads (>0.002 secs).\n(always falls WITHIN ambitus: automatically adjusted where too large)"],
            ["clock",   0,      None,   "Time between segment reads = seg duration (> SPLICELEN * 2).(secs)."],
            ["-s",      0,      None,   "in MILLIsecs (default 15ms)."],
            ["-c",      0,      1,      "Randomisation of clock-ticks. (Range : 0-1: default 0)"],
            ["-o",      0,      0.9900, "Mutual overlap of segments in output. (Range 0 to 0.9900: default 0)."],
            ["-r",      None,   None,   "Any set value gives REPRODUCIBLE output."]
        ]
cdp.extend.drunk.add_mode(1, params)
params.extend([
            ["mindrnk", 1,      32767,  "Min no. cloktiks between sober plays (1 - 32767: Default 10)"],
            ["maxdrnk", 1,      32767,  "Max no. cloktiks between sober plays (1 - 32767: Default 30)"],
            ["-l",      0,      None,   "Min duration of sober plays (secs) (Range: >0 - infiledur+)\nIf >= infiledur (default): sober plays all go to end of src"],
            ["-h",      0,      None,   "Max duration of sober plays (secs) (Range: >0 - infiledur+)"]
    ])
cdp.extend.drunk.add_mode(2, params)

#
# MODIFY    ----------------------------------------
#
#
# MODIFY BRASSAGE
#
cdp.modify.add_process("brassage", "-", "-", 7, "GRANULAR RECONSTITUTION OF SOUNDFILE")

params = [["pitchshift", None, None, "is pitchshift in +|- (fractions of) semitones."]]
cdp.modify.brassage.add_mode(1, params, "PITCHSHIFT")

params = [["velocity", 0, None, "speed of advance in infile, relative to outfile. (>=0)\nThis is inverse of timestretch, (& permits infinite timestretch)."]]
cdp.modify.brassage.add_mode(2, params, "TIMESTRETCH")

params = [["density", 0, 1, "amount of grain overlap (>0 : <1 leaves intergrain silence)\nExtremely small values will cease to perform predictably."],
        ["pitch", None, None],
        ["amp", 0, 1, "gain on grains\nuse only if you want amp to vary (over a range &/or in time)"],
        ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."]]
cdp.modify.brassage.add_mode(3, params, "REVERB")

params = [["grainsize", 50, 50, "grainsize in MS (must be > 2 * splicelen) (Default 50)"],
        ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."]]
cdp.modify.brassage.add_mode(4, params, "SCRAMBLE")

params = [["density", 0, 1, "amount of grain overlap (>0 : <1 leaves intergrain silence)\nExtremely small values will cease to perform predictably."]]
cdp.modify.brassage.add_mode(5, params, "GRANULATE")

br_params = [["velocity", 0, None],
        ["density", 0, 1],
        ["grainsize", 50, 50],
        ["pitchshift", None, None],
        ["amp", 0, 1],
        ["space", 0, 1, "set stereo position in outputfile. 0=L,1=R    (Range 0-1).\nSpace flag on STEREO input, mixes it to mono before acting."],
        ["bsplice", 0, None, "length of startsplices on grains,in MS (Default 5)"],
        ["esplice", 0, None, "length of endsplices on grains,in MS (Default 5)"],
        ]
params = br_params
params.extend([
    ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."],
    ["-j", 0, 1, "jitter"],
    ["-l", 0, None, "outlength"],
    ["-c", 0, 2, "Extract & work on just 1 channel of stereo snd: Range(1-2)."],
    ["-x", None, None, "do exponential splices."],
    ["-n", None, None, "no interpolation for pitch vals."] ])
cdp.modify.brassage.add_mode(6, params, "BRASSAGE")

params = br_params
params.extend([["hvelocity", 0, None],
    ["hdensity", 0, 1, "high density"],
    ["hgrainsize", 50, 50, "high grainsize"],
    ["hpitchshift", None, None, "high pitchshift"],
    ["hamp", 0, 1, "high amp"],
    ["hspace", 0, 1, "(high) set stereo position in outputfile. 0=L,1=R    (Range 0-1).\nSpace flag on STEREO input, mixes it to mono before acting."],
    ["hbsplice", 0, None, "(high) length of startsplices on grains,in MS (Default 5)"],
    ["hesplice", 0, None, "(high) length of endsplices on grains,in MS (Default 5)"],
    ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."],
    ["-j", 0, 1, "jitter"],
    ["-l", 0, None, "outlength"],
    ["-c", 0, 2, "Extract & work on just 1 channel of stereo snd: Range(1-2)."],
    ["-x", None, None, "do exponential splices."],
    ["-n", None, None, "no interpolation for pitch vals."]])
cdp.modify.brassage.add_mode(7, params, "FULL MONTY")

#
# MODIFY SAUSAGE
#
cdp.modify.add_process("sausage", "-", "-", None, "GRANULAR RECONSTITUTION OF SEVERAL SOUNDFILES SCRAMBLED TOGETHER.")

#
# MODIFY REVECHO
#
cdp.modify.add_process("revecho", "-", "-", 3, "CREATE REVERB, ECHO, OR RESONANCE AROUND SOUND")
params = [
            ["delay", 0, None],
            ["mix", 0, 1],
            ["feedback", 0, 1],
            ["tail", 0, None],
            ["-p", None, None, "prescale"]
         ]

cdp.modify.revecho.add_mode(1, params, "STANDARD DELAY")

params = [
            ["delay", 0, None],
            ["mix", 0, 1],
            ["feedback", 0, 1],
            ["lfomod", 0, 1],
            ["lfofreq", None, None],
            ["lfodelay", 0, None],
            ["tail", 0, None],
            ["-p", None, None, "prescale"]
         ]

cdp.modify.revecho.add_mode(2, params, "VARYING DELAY")

params = [
            ["-g", 0, None, "Gain"],
            ["-r", 0, 1,    "Roll off"],
            ["-s", 0, None, "Size"],
            ["-e", 0, 1000, "Echo count"],
         ]

cdp.modify.revecho.add_mode(3, params, "STADIUM ECHO")

cdp.modify.add_process("loudness", "-", "-", 12, "ADJUST LOUDNESS OF A SOUNDFILE")

params = [["-l", 0, 1, "level"]]
cdp.modify.loudness.add_mode(3, params, "NORMALISE")

#
# MODIFY SPACE
#
cdp.modify.add_process("space", "-", "-", 4, "CREATE OR ALTER DISTRIBUTION OF SOUND IN STEREO SPACE")

#
# MODIFY SPACEFORM - Special Case, Creates Space Data File
#

cdp.modify.add_process("space", "-", "D", None, "CREATE A SINUSOIDAL SPATIAL DISTRIBUTION DATA FILE")

#
# MODIFY SPEED
#
cdp.modify.add_process("speed", "-", "-", 6, "CHANGE THE SPEED & PITCH OF THE SRC SOUND.")

#
# MODIFY CONVOLVE - infile2 must NOT be longer than infile1, both files must have same channel count
#
cdp.modify.add_process("convolve", "-", "-", 2, "CONVOLVE THE FIRST SOUND WITH THE SECOND.")

#
# SFEDIT    ----------------------------------------
#
#
# SFEDIT CUT
#
cdp.sfedit.add_process("cut", "-", "-", 3, "CUT & KEEP A SEGMENT OF A SOUND.")

params = [
            ["start", 0, None],
            ["end", 0, None]
         ] 
cdp.sfedit.cut.add_mode(1, params)
cdp.sfedit.cut.add_mode(2, params)
cdp.sfedit.cut.add_mode(3, params)

#
# FILTER    ----------------------------------------
#
#
# FILTER LOHI
#
#cdp.filter.add_process("lohi", "-", "-", 2, "FIXED LOW PASS OR HIGH PASS FILTER.")
#params = [
#            ["attenuation", -96, 0],
#            ["pass-band", 0, None],
#            ["stop-band", 0, None]
#         ] 
#cdp.filter.lohi.add_mode(1, params, "Pass-band and stop-band as freq in Hz.")
#cdp.filter.lohi.add_mode(2, params, "Pass-band and stop-band as (possibly fractional) midi notes.")

#
# FILTER
#
#
# FILTER BANK
#
# CDP Release 5 2005
# BANK OF FILTERS, WITH TIME-VARIABLE Q
# 
# USAGE: filter bank 1-3 infile outfile Q gain lof hif       [-ttail] [-sscat] [-d]
# OR:    filter bank 4-6 infile outfile Q gain lof hif param [-ttail] [-sscat] [-d]
# 
# MODES...
# 1)  HARMONIC SERIES over lofrq.
# 2)  ALTERNATE HARMONICS over lofrq.
# 3)  SUBHARMONIC SERIES below hifrq.
# 4)  HARMONIC SERIES WITH LINEAR OFFSET: param = offset in Hz.
# 5)  EQUAL INTERVALS BETWEEN lo & hifrq: param = no. of filters.
# 6)  EQUAL INTERVALS BETWEEN lo & hifrq: param = interval semitone-size.
# 
# Q      Q (tightness) of filters (Range 0.001000 <= Q < 10000.0)
# GAIN   overall gain (Range 0.001000 to 10000.0).
# LOF    lofrq limit of filters  (Range: 10 to srate/3).
# HIF    hifrq limit of filters  (Range: lofrq+ to srate/3).
# TAIL   decay tail duration
# SCAT   Random scatter of filter frqs (Range 0 to 1: Default 0).
# -d     Double filtering.
# 
# Q may vary over time.
# 
# 
cdp.filter.add_process("bank", "sndfile", "sndfile", 6, "Bank of filters, with time-variable Q.")
params = [
        ['Q',    0.001000,  10000.0,    "Q (tightness) of filters (Range 0.001000 <= Q < 10000.0)"],
        ['gain', 0.00100,   10000.0,    "overall gain (Range 0.001000 to 10000.0)."],
        ['lof',  10,        SAMPLE_RATE/3,    "lofrq limit of filters  (Range: 10 to srate/3)."],
        ['hif',  0.00100,   SAMPLE_RATE/3,    "hifrq limit of filters  (Range: lofrq+ to srate/3)."],
        ['-t',   0,         None,       "decay tail duration"],
        ['-s',   0,         None,       "Random scatter of filter frqs (Range 0 to 1: Default 0)"],
        ['-d',   None,      None,       "Double filtering"]
        ]

cdp.filter.bank.add_mode(1, params, "HARMONICS")
cdp.filter.bank.add_mode(2, params, "ALTERNATE HARMONICS")
cdp.filter.bank.add_mode(3, params, "SUBHARMONICS")

params.extend([['param', None, 22050.0, "offset in Hz."]])

cdp.filter.bank.add_mode(4, params, "HARMONICS WITH OFFSET")

params.pop()

params.extend([['param', None, None, "no. of filters."]])

cdp.filter.bank.add_mode(5, params, "FIXED NUMBER OF BANDS")

params.pop()

params.extend([['param', None, None, "interval semitone-size."]])

cdp.filter.bank.add_mode(6, params, "FIXED INTERVAL BETWEEN")

#
# BLUR
#
#
# BLUR AVRG
#
# CDP Release 5 2005
# blur avrg infile outfile N
# 
# AVERAGE SPECTRAL ENERGY OVER N ADJACENT CHANNELS
# 
# N must be ODD and <= half the -N param used in original analysis.
# 
# N may vary over time.
# 
# 
cdp.blur.add_process("avrg", "analfile", "analfile", None, "Average spectral energy over N adjacent channels.")
params = [
        ["N", 0, None, "N must be ODD and <= half the -N param used in original analysis."]
        ]
cdp.blur.avrg.add_parameters(params)
#
# BLUR BLUR
#
# CDP Release 5 2005
# blur blur infile outfile blurring
# 
# TIME-AVERAGE THE SPECTRUM
# 
# blurring   is number of windows over which to average the spectrum.
# 
# blurring may vary over time. 
# 
# 
cdp.blur.add_process("blur", "analfile", "analfile", None, "Time-average the spectrum.")
params = [
        ["blurring", 0, None, "number of windows over which to average the spectrum"]
        ]
cdp.blur.blur.add_parameters(params)
#
# BLUR CHORUS
#
# CDP Release 5 2005
# blur chorus 1   infile outfile aspread        
# blur chorus 2-4 infile outfile         fspread
# blur chorus 5-7 infile outfile aspread fspread
# 
# CHORUSING BY RANDOMISING AMPLITUDES AND/OR FREQUENCIES OF PARTIALS
# 
# MODES :-
# 1  Randomise partial amplitudes.
# 2  Randomise partial frequencies.
# 3  Randomise partial frequencies upwards only.
# 4  Randomise partial frequencies downwards only.
# 5  Randomise partial amplitudes AND frequencies.
# 6  Randomise partial amplitudes, and frequencies upwards only.
# 7  Randomise partial amplitudes, and frequencies downwards only.
# 
# aspread   is maximum random scatter of partial-amps (Range 1-1028)
# fspread   is maximum random scatter of partial-frqs (Range 1-4)
# 
# aspread and fspread may vary over time.
# 
# 
cdp.blur.add_process("chorus", "analfile", "analfile", 7, "Chorus effect by randomising amplitudes &/or frequencies of partials.")
params = [
        ["aspread", 1, 1028, "maximum random scatter of partial-amps"]
        ]
cdp.blur.chorus.add_mode(1, params, "SCATTER AMPS")
params = [
        ["fspread", 1, 4, "maximum random scatter of partial-frqs"]
        ]
cdp.blur.chorus.add_mode(2, params, "SCATTER FRQS")
cdp.blur.chorus.add_mode(3, params, "SCATTER FRQS UP")
cdp.blur.chorus.add_mode(4, params, "SCATTER FRQS DOWN")
params = [
        ["aspread", 1, 1028, "maximum random scatter of partial-amps"],
        ["fspread", 1, 4, "maximum random scatter of partial-frqs"]
        ]
cdp.blur.chorus.add_mode(5, params, "SCATTER AMPS & FRQS")
cdp.blur.chorus.add_mode(6, params, "SCATTER AMPS,& FRQS UP")
cdp.blur.chorus.add_mode(7, params, "SCATTER AMPS,& FRQS DOWN")
#
# BLUR DRUNK
#
# CDP Release 5 2005
# blur drunk infile outfile range starttime duration [-z]
# 
# MODIFY SOUND BY DRUNKEN WALK ALONG ANALYSIS WINDOWS.
# 
# RANGE     is maximum step (in windows) for drunken walk.
# STARTTIME is time (in secs) in file to begin walk.
# DURATION  is required duration of outfile after resynthesis.
# -z        eliminates zero steps (window-repeats) in the drunken walk.
# 
# 
# 
cdp.blur.add_process("drunk", "analfile", "analfile", None, "Modify sound by drunken walk along analysis windows.")
params = [
        ["range", 0, None, "maximum step (in windows) for drunken walk"],
        ["starttime", 0, None, "time (in secs) in file to begin walk"],
        ["duration", 0, None, "duration of outfile after resynthesis"],
        ["-z", None, None, "eliminates zero steps (window-repeats) in the drunken walk"]
        ]
cdp.blur.drunk.add_parameters(params)
#
# BLUR NOISE
#
# CDP Release 5 2005
# blur noise infile outfile noise
# 
# PUT NOISE IN THE SPECTRUM
# 
# noise   Range 0 (no noise in spectrum) to 1 (spectrum saturated with noise).
# 
# noise may vary over time.
# 
# 
cdp.blur.add_process("noise", "analfile", "analfile", None, "Put noise in the spectrum.")
params = [
        ["noise", 0.0, 1.0, "0 (no noise in spectrum) to 1 (spectrum saturated with noise)"]
        ]
cdp.blur.noise.add_parameters(params)
#
# BLUR SCATTER
#
# CDP Release 5 2005
# blur scatter infile outfile keep [-bblocksize] [-r] [-n] 
# 
# RANDOMLY THIN OUT THE SPECTRUM
# 
# keep      number of (randomly-chosen) blocks to keep, in each spectral window.
# blocksize is freq range of each block (default is width of 1 analysis channel).
#           (Rounded internally to a multiple of channel width).
# -r        number of blocks actually selected is randomised between 1 & keep.
# -n        Turn OFF normalisation of resulting sound.
# 
# keep & blocksize may vary over time.
# 
# 
cdp.blur.add_process("scatter", "analfile", "analfile", None, "Randomly thin out the spectrum.")
params = [
        ["keep", 0, None, "number of (randomly-chosen) blocks to keep, in each spectral window."],
        ["blocksize", 0, None, "freq range of each block (default is width of 1 analysis channel). (Rounded internally to a multiple of channel width)."],
        ["-r", None, None, "number of blocks actually selected is randomised between 1 & keep"],
        ["-n", None, None, "Turn OFF normalisation of resulting sound."]
        ]
cdp.blur.scatter.add_parameters(params)
#
# BLUR SHUFFLE
#
# CDP Release 5 2005
# blur shuffle infile outfile domain-image grpsize
# 
# SHUFFLE ORDER OF ANALYSIS WINDOWS IN FILE
# 
# domain-image is 2 strings of letters, separated by a '-'
# The first string is the DOMAIN, and the 2nd, the IMAGE.
# 
# e.g. 'abc-abbabcc'
# 
# The DOMAIN letters represent a group of consecutive inputfile analysis_windows.
# 
# e.g. 'abcd'
# 
# The IMAGE is any permutation of, or selection from, these domain letters.
# (domain letters may be omitted or repeated in the image string).
# 
# e.g. 'aaaaaaadaaa'
# 
# Inputfile windows are shuffled according to this same mapping.
# 
# grpsize Windows may be grouped in sets of GRPSIZE
#         before being shuffled (as groups).
#         In this case,each domain-letter represents a group of GRPSIZE windows.
# 
# 
# 
cdp.blur.add_process("shuffle", "analfile", "analfile", None, "Shuffle order of analysis windows in file.")
params = []
cdp.blur.shuffle.add_parameters(params)
cdp.blur.shuffle.note = "This is an unusual process, will take time to implement."
#
# BLUR SPREAD
#
# CDP Release 5 2005
# blur spread infile outfile -fN|-pN [-i] [-sspread]
# 
# SPREAD PEAKS OF SPECTRUM, INTRODUCING CONTROLLED NOISINESS
# 
# -f   extract formant envelope linear frqwise,
#      using 1 point for every N equally-spaced frequency-channels.
# -p   extract formant envelope linear pitchwise,
#      using N equally-spaced pitch-bands per octave.
# -i   quicksearch for formants (less accurate).
# 
# spread    degree of spreading of spectrum (Range 0-1 : Default 1).
# 

# spread may vary over time.
# 
# 
cdp.blur.add_process("spread", "analfile", "analfile", None, "Spread peaks of spectrum, introducing controlled noisiness.")
params = [
        ["-f", 1, None, "extract formant envelope linear frqwise, using 1 point for every N equally-spaced frequency-channels."],
        ["-p", 1, None, "extract formant envelope linear pitchwise, using N equally-spaced pitch-bands per octave."],
        ["-i", None, None, "extract formant envelope linear pitchwise, using N equally-spaced pitch-bands per octave."]
        ]
cdp.blur.spread.add_parameters(params)
#
# BLUR SUPPRESS
#
# CDP Release 5 2005
# blur suppress infile outfile N
# 
# SUPPRESS THE N LOUDEST PARTIALS (ON A WINDOW-BY-WINDOW BASIS)
# 
# N   is number of spectral components to reject.
# 
# N may vary over time.	
# 
# 
cdp.blur.add_process("suppress", "analfile", "analfile", None, "Suppress N loudest partials (on a window-by-window basis).")
params = [
        ["N", 0, None, "number of spectral components to reject"]
        ]
cdp.blur.suppress.add_parameters(params)
#
# BLUR WEAVE
#
# CDP Release 5 2005
# blur weave infile outfile weavfile
# 
# MODIFY SOUND BY WEAVING AMONGST ANALYSIS WINDOWS.
# 
# WEAVFILE contains a list of integers which define successive steps (in windows)
# through the input file. Steps may be forward or backwards.
# The step sequence is repeated until end of infile is reached.
# 
# Weave must obey the following rules....
# 
# RULE 1:  NO step can exceed the length of the file, in windows, forwards or backwards.
# RULE 2:  NO window reached in a weave can be BEFORE startwindow of the weave.
# RULE 3:  FINAL window must be AFTER the weave startwindow.
# 
# Otherwise, weave may be forward or backward, or remain at same window.
# 
# 
# 
cdp.blur.add_process("weave", "analfile", "analfile", None, "Modify sound by weaving amongst analysis windows.")
params = []
cdp.blur.weave.add_parameters(params)
cdp.blur.weave.note = "This is another weird one. TODO:"
#
# FILTER FIXED
#
# CDP Release 5 2005
# CUT OR BOOST, ABOVE, BELOW OR AROUND A GIVEN FRQ
# 
# USAGE: filter fixed 1-2  infile outfile        boost/cut freq [-ttail] [-sprescale]
# OR:    filter fixed 3    infile outfile bwidth boost/cut freq [-ttail] [-sprescale]
# 
# MODES ARE...
# 1) BOOST OR CUT BELOW GIVEN FRQ
# 2) BOOST OR CUT ABOVE GIVEN FRQ
# 3) BOOST OR CUT A BAND CENTERED ON GIVEN FRQ
# 
# BWIDTH     is the filter bandwidth in Hz for Mode 3 only
# BOOST/CUT  is the boost or cut, in dB
# FREQ       is the filter frequency in Hz
# TAIL       decay tail duration
# PRESCALE   scales the INPUT to the filter.
# 
# 
cdp.filter.add_process("fixed", "sndfile", "sndfile", 3, "Cut or boost - above, below or around a given frequency.")
params = []
cdp.filter.fixed.add_mode(1, params, "BOOST-OR-CUT BELOW FRQ")
params = []
cdp.filter.fixed.add_mode(2, params, "BOOST-OR-CUT ABOVE FRQ")
params = []
cdp.filter.fixed.add_mode(3, params, "BOOST-OR-CUT AROUND FRQ")
#
# FILTER ITERATED
#
# CDP Release 5 2005
# ITERATE SOUND, WITH CUMULATIVE FILTERING BY A FILTERBANK.
# 
# USAGE: filter iterated mode infile outfile datafile Q gain delay dur 
#          [-sprescale] [-rrand] [-ppshift] [-aashift] [-d] [-i] [-e] [-n]
# 
# MODES ARE...
# 1)  Enter filter-pitches as frq, in Hz.
# 2)  Enter filter-pitches as MIDI values.
# 
# DATAFILE  has Pitch & Amp of filters (paired, one pair on each line).
#           Pitch, as Hz or MIDI, Range(10Hz to srate/3)
#           Amp, Range(0.001000 to 10000.0), can also be entered as dB vals
# 
# Q         Q (tightness) of filter: Range(0.001000 to 10000.0)
# GAIN      overrall gain in filtering process (0.001000 < gain < 10000.0)
# DELAY     (average) delay between iterations (secs).
#           Range(>0 to 32767)
# DUR       (min) duration of output file (>infile duration).
# PRESCALE  gain on the INPUT to the filtering process.
#           Range (0.0 - 1.0) Default 1.0
#           If set to 0.0, Program automatically divides input level by
#           the max no. of sound overlays occuring in the iteration process.
# RAND      delaytime-randomisation: Range 0 (none) to 1 (max).
# PSHIFT    max pitchshift of any segment in (fractions of) semitones (>=0).
# ASHIFT    max amplitude reduction of any segment: Range (0.0 - 1.0)
# -d        double filtering.
# -i        Turn off Interpolation during pitch shift: (fast but dirty).
# -e        Exponential decay added: each seg gets quieter before next enters.
# -n        turns OFF normalisation: segs may grow or fall in level quickly.
# 
# 
cdp.filter.add_process("iterated", "sndfile", "sndfile", 2, "Iterate sound, with cumulative filtering by a filterbank.")
params = []
cdp.filter.iterated.add_mode(1, params, "BANDS AS FRQ (HZ)")
params = []
cdp.filter.iterated.add_mode(2, params, "BANDS AS MIDI")
#
# FILTER LOHI
#
# CDP Release 5 2005
# FIXED LOW PASS OR HIGH PASS FILTER.
# 
# USAGE:
# filter lohi mode infile outfile attenuation pass-band stop-band [-ttail] [-sprescale]
# 
# MODES ARE
# 1) Pass-band and stop-band as freq in Hz.
# 2) Pass-band and stop-band as (possibly fractional) midi notes.
# 
# ATTENUATION Gain reduction of filter, in dB. Range(0 to -96)
#             Greater attenuation, sharper filter, but longer to calculate.
# PASS-BAND   last pitch to be passed by the filter.
# STOP-BAND   first pitch to be stopped by the filter.
#             If stop-band is above pass-band, this is a lopass filter.
#             If stop-band is below pass-band, this is a hipass filter.
# TAIL       decay tail duration
# -s          Prescale input: Avoid overflows: Range(0.005 to 200.0)
# 
# 
cdp.filter.add_process("lohi", "sndfile", "sndfile", 2, "Fixed low pass or high pass filter.")
params = []
cdp.filter.lohi.add_mode(1, params, "BANDS AS FRQ (HZ)")
params = []
cdp.filter.lohi.add_mode(2, params, "BANDS AS MIDI")
#
# FILTER PHASING
#
# CDP Release 5 2005
# PHASESHIFT SOUND, OR PRODUCE 'PHASING' EFFECT
# 
# USAGE: filter phasing mode infile outfile gain delay [-ttail] [-sprescale] [-l]
# 
# MODES ARE..
# 1) ALLPASS FILTER (PHASE-SHIFTED)
# 2) PHASING EFFECT
# 
# GAIN      Range (-1.0 to 1.0)
#           In MODE 2, phasing effect increases as gain increases from -1
#           BUT a gain of 1.0 will produce complete phase cancellation
#           and the output signal will be zero.
# DELAY     >0.0 MS
# TAIL      decay tail duration
# PRESCALE  gain on the INPUT to the filtering process.
#           Range (0.0 - 1.0) Default 1.0
# -l        linear interpolation of changing delay vals (default: logarithmic)
# 
# DELAY may vary over time.
# 
# 
cdp.filter.add_process("phasing", "sndfile", "sndfile", 2, "Phase shift sound, or produce 'phasing' effect.")
params = []
cdp.filter.phasing.add_mode(1, params, "PHASE SHIFT FILTER")
params = []
cdp.filter.phasing.add_mode(2, params, "PHASING EFFECT")
#
# FILTER SWEEPING
#
# CDP Release 5 2005
# FILTER WHOSE FOCUS-FREQUENCY SWEEPS OVER A RANGE OF FREQUENCIES
# 
# USAGE:
# filter sweeping mode infile outfile acuity gain lofrq hifrq sweepfrq [-ttail] [-pphase]
# 
# MODES ARE...
# 1) HIGH-PASS   3) BAND-PASS
# 2) LOW-PASS    4) NOTCH (Band-reject).
# 
# ACUITY   Acuity of filter:  Range(0.000100 to 1.0)
#          Smaller vals give tighter filter.
# GAIN     overall gain on output:   Range(0.001000 to 10000.0)
#          Rule of thumb:
#          if acuity = (1/3)to-power-n: gain = (2/3)-to-power-n
# LOFRQ    lowest frq to sweep to:   Range(10.0 to srate/2)
# HIFRQ    highest frq to sweep to:  Range(10.0 to srate/2)
# SWEEPFRQ frq of the sweep itself:  Range(0.0 to 200.0)
#          e.g. to sweep once over range, set sweepfrq to infiledur/2 (default)
#          and set phase to 0 (upsweep) or .5(downsweep)
# TAIL      decay tail duration
# PHASE    start of sweep: Range(0-1)
#          vals are: 0 = (lofrq) rising to .5 = (hifrq) falling to 1 = (lofrq).
#          Default value is .25 (midfrq,rising)
# 
# ACUITY, LOFRQ, HIFRQ and SWEEPFRQ may all vary over time.
# This filter is most effective in BAND-PASS or LOW-PASS mode, at low ACUITY.
# 
# 
cdp.filter.add_process("sweeping", "sndfile", "sndfile", 4, "Filter whose focus-frequency sweeps over a range.")
params = []
cdp.filter.sweeping.add_mode(1, params, "HIGH PASS")
params = []
cdp.filter.sweeping.add_mode(2, params, "LOW PASS")
params = []
cdp.filter.sweeping.add_mode(3, params, "BAND PASS")
params = []
cdp.filter.sweeping.add_mode(4, params, "NOTCH")
#
# FILTER USERBANK
#
# CDP Release 5 2005
# USER-DEFINED FILTERBANK,WITH TIME-VARIABLE Q
# 
# USAGE: filter userbank mode infile outfile datafile Q gain [-ttail] [-d]
# 
# MODES are
# 1)  Filter-pitches as frq in Hz.
# 2)  Filter-pitches as MIDI values.
# 
# DATAFILE: has Pitch & Amp of filters (paired, one pair on each line).
#           Ranges: Pitch (10Hz to sr/3) Amp (0.001000 to 10000.0)
#           Amplitude may also be expressed in decibels.
#           Comment-lines (starting with ';') may be used.
# 
# Q:        Q (tightness) of filter: Range(0.001000 to 10000.0)
# GAIN      overall gain, Range(0.001000 to 10000.0).
# TAIL      decay tail duration
# -d        double filtering.
# 
# Q may vary over time.
# 
cdp.filter.add_process("userbank", "sndfile", "sndfile", 2, "User-defined filterbank, with time-variable Q.")
params = []
cdp.filter.userbank.add_mode(1, params, "BANDS AS FRQ (HZ)")
params = []
cdp.filter.userbank.add_mode(2, params, "BANDS AS MIDI")
#
# FILTER VARIABLE
#
# CDP Release 5 2005
# LOPASS, HIGH-PASS, BANDPASS, OR NOTCH FILTER WITH VARIABLE FRQ
# 
# USAGE: filter variable mode infile outfile acuity gain frq [-ttail]
# 
# MODES ARE..
# 1) HIGH-PASS
# 2) LOW-PASS
# 3) BAND-PASS
# 4) NOTCH (Band Reject)
# 
# ACUITY   acuity of filter: Range(0.000100 to 1.0).
#          Smaller vals give tighter filter.
# GAIN     overall gain on output:  Range(0.001000 to 10000.0)
#          Rule of thumb:
#          if acuity = (1/3)to-power-n: gain = (2/3)-to-power-n
# FRQ      frq of filter:           Range(10.0 to srate/2)
# 
# ACUITY and FRQ can vary over time.
# TAIL       decay tail duration
# 
# 
cdp.filter.add_process("variable", "sndfile", "sndfile", 4, "Lopass, hipass, bandpass, or notch filter of variable frequency.")
params = []
cdp.filter.variable.add_mode(1, params, "HIGH PASS")
params = []
cdp.filter.variable.add_mode(2, params, "LOW PASS")
params = []
cdp.filter.variable.add_mode(3, params, "BAND PASS")
params = []
cdp.filter.variable.add_mode(4, params, "NOTCH")
#
# FILTER VARIBANK
#
# CDP Release 5 2005
# USER-DEFINED TIME_VARYING FILTERBANK,WITH TIME-VARIABLE Q
# 
# USAGE:
# filter varibank mode infile outfile data Q gain [-ttail] [-hhcnt] [-rrolloff] [-d]
# 
# MODES ARE...
# 1)  Enter filter-pitches as frq, in Hz.
# 2)  Enter filter-pitches as MIDI values.
# 
# DATAFILE: has lines of data for filter bands at successive times.
#           Each line contains the following items
#                 Time:   Pitch1 Amp1   [Pitch2 Amp2    etc....].
#           Pitch and Amp values must be paired:
#           any number of pairs can be used in a line,
#           BUT each line must have SAME number of pairs on it.
#           (To eliminate a band in any line(s), set its amplitude to 0.0).
#           Time values (in secs) must be in ascending order (and >=0.0)
#           Pitch vals may be EITHER frq, OR MIDI, depending on MODE.
#           Amp values may be numeric, or dB values (e.g. -4.1dB).
#           Comment-lines may be used: start these with ';'.
# 
# Q         Q (tightness) of filter : Range(0.001000 to 10000.0).
# GAIN:     overall gain: Range: (0.001000 to 10000.0)
# TAIL      decay tail duration
# HCNT      No of harmonics of each pitch to use: Default 1.
#           High harmonics of high pitches may be beyond nyquist.
#           (No-of-pitches times no-of-harmonics determines program speed).
# ROLLOFF   Level drop (in dB) from one harmonic to next. Range(0 to -96.0)
# -d        double filtering.
# 
# Q may also vary over time.
# 
# 
cdp.filter.add_process("varibank", "sndfile", "sndfile", 2, "User-defined time-varying filterbank, with time-variable Q.")
params = []
cdp.filter.varibank.add_mode(1, params, "BANDS AS FRQ (HZ)")
params = []
cdp.filter.varibank.add_mode(2, params, "BANDS AS MIDI")
#
# FILTER VARIBANK2
#
# CDP Release 5 2005
# USER-DEFINED TIME_VARYING FILTERBANK,WITH TIME-VARIABLE Q AND PARTIALS
# USAGE:
# filter varibank2 mode infil outfil data Q gain [-ttail] [-d]
# MODES ARE...
# 1)  Enter filter-pitches as frq, in Hz.
# 2)  Enter filter-pitches as MIDI values.
# 
# DATAFILE: has lines of data for filter bands at successive times.
#           as varibank filter....
#           Followed by a line with a '#' sign at the start.
#           Followed by 2nd set of lines, similar to the pitchdata lines
#           but now the data is a time followed by any number of pairs of
#           partial number (possibly fractional) + amplitude of partial.
#           Times for pitch AND for partials data MUST START AT ZERO.
# Q         Q (tightness) of filter : Range(0.001000 to 10000.0).
# GAIN:     overall gain: Range: (0.001000 to 10000.0)
# TAIL      decay tail duration
# -d        double filtering.
# 
# Q may also vary over time.
# 
# 
cdp.filter.add_process("varibank2", "sndfile", "sndfile", 2, "User-defined time-varying filterbank, with time-variable Q and partials.")
params = []
cdp.filter.varibank2.add_mode(1, params, "BANDS AS FRQ (HZ)")
params = []
cdp.filter.varibank2.add_mode(2, params, "BANDS AS MIDI")
#
# FILTER VFILTERS
#
# CDP Release 5 2005
# MAKE FIXED-PITCH DATA-FILES FOR VARIBANK FILTER
# 
# USAGE: filter vfilters inpitchfile outfile
# 
# INPITCHFILE     Textfile, contains a list of MIDI or FRQ pitch values
#                 with one or more values on each line.
# Each line is converted to a data file for a fixed pitch(es) filter,
# of the 'varibank' type.
# Producing outfile0.txt, outfile1.txt etc.
# 
# 
cdp.filter.add_process("vfilters", "sndfile", "sndfile", None, "Make (text) datafiles for fixed-pitch FILTER VARIBANK filters.")
params = []
cdp.filter.vfilters.add_parameters(params)
#
# FOCUS
#
#
# FOCUS ACCU
#
# CDP Release 5 2005
# focus accu infile outfile [-ddecay] [-gglis]
# 
# SUSTAIN EACH SPECTRAL BAND, UNTIL LOUDER DATA APPEARS IN THAT BAND
# 
# -d    sutained channel data decays by factor DECAY per sec.
#       (Possible Range : 0.001000 to 1.0 : Default 1.0)
#       (Suggested Effective Range : 0.001000 to 0.5)
# -g    sutained channel data glisses at GLIS 8vas per sec.
#       (Approx Range : -11.7 to 11.7 : Default 0)
# 
# 
# 
cdp.focus.add_process("accu", "analfile", "analfile", None, "Sustain spectral bands, until louder data appears in band.")
params = []
cdp.focus.accu.add_parameters(params)
#
# FOCUS EXAG
#
# CDP Release 5 2005
# focus exag infile outfile exaggeration
# 
# EXAGGERATE SPECTRAL CONTOUR
# 
# exaggeration >0 will widen troughs: <0 will widen peaks.
# 
# exaggeration may vary over time.
# 
# 
# 
cdp.focus.add_process("exag", "analfile", "analfile", None, "Exaggerate spectral contour.")
params = []
cdp.focus.exag.add_parameters(params)
#
# FOCUS FOCUS
#
# CDP Release 5 2005
# focus focus infile outfile -fN|-pN [-i] pk bw [-bbt] [-ttp] [-sval]
# 
# FOCUS SPECTRAL ENERGY ONTO PEAKS IN SPECTRUM
# 
# -f     extract formant envelope linear frqwise,
#        using 1 point for every N equally-spaced frequency-channels.
# -p     extract formant envelope linear pitchwise,
#        using N equally-spaced pitch-bands per octave.
# -i   quicksearch for formants (less accurate).
# pk   (max) number of peaks to find : Range 1 - 16
# bw   bandwidth of peak-centred filters, in octaves.
# -b   BT is bottom frequency to start peak search.
# -t   TP is top frequency to end peak search.
# -s   Attempt to retain only peaks which are STABLE over time.
#        Range 2 - 4097 : default 9 : is no. of windows over which peaks averaged.
# 
# bandwidth,bottom frequency & top frequency may vary over time.
# 
# 
# 
cdp.focus.add_process("focus", "analfile", "analfile", None, "Focus spectral energy onto peaks in spectrum.")
params = []
cdp.focus.focus.add_parameters(params)
#
# FOCUS FOLD
#
# CDP Release 5 2005
# focus fold infile outfile lofrq hifrq [-x]
# 
# OCTAVE-TRANSPOSE SPECTRAL COMPONENTS INTO SPECIFIED RANGE
# 
# lofrq & hifrq specify range into which spectrum is folded,
# -x            Fuller spectrum.
# 
# lofrq & hifrq  may vary over time. 
# 
# 
cdp.focus.add_process("fold", "analfile", "analfile", None, "Octave-transpose spectral components into specified range.")
params = []
cdp.focus.fold.add_parameters(params)
#
# FOCUS FREEZE
#
# CDP Release 5 2005
# focus freeze mode infile outfile datafile
# 
# FREEZE SPECTRAL CHARACTERISTICS IN SOUND, AT GIVEN TIMES 
# 
# Datafile contains times at which spectrum is frozen.
# These times may be preceded by character MARKERS....
# 
# a   use window here as freezewindow for spectrum AFTER this time.
# b   use window here as freezewindow for spectrum BEFORE this time.
# 
# Otherwise, times are end\start of freeze established at one of these markers.
# 
# MODES
# 1   freeze channel amplitudes
# 2   freeze channel frequencies
# 3   freeze channel amplitudes & frequencies
# 
# 
# 
cdp.focus.add_process("freeze", "analfile", "analfile", 3, "Freeze spectral characteristics in sound, at given times.")
params = []
cdp.focus.freeze.add_mode(1, params, "AMPLITUDES")
params = []
cdp.focus.freeze.add_mode(2, params, "FREQUENCIES")
params = []
cdp.focus.freeze.add_mode(3, params, "AMPS & FRQS")
#
# FOCUS HOLD
#
# CDP Release 5 2005
# focus hold infile outfile datafile
# 
# HOLD SOUND SPECTRUM, AT GIVEN TIMES 
# 
# Datafile contains times at which spectrum is held, & hold-duration.
# These data items must be paired correctly.
# The process expands each hold window to the duration given,
# before proceeding to the next window. The output file is therefore longer
# than the input file.
# 
# 
# 
cdp.focus.add_process("hold", "analfile", "analfile", None, "Hold sound spectrum, at given times")
params = []
cdp.focus.hold.add_parameters(params)
#
# FOCUS STEP
#
# CDP Release 5 2005
# focus step infile outfile timestep
# 
# STEP-FRAME THROUGH SOUND BY FREEZING SPECTRUM AT REGULAR TIME INTERVALS
# 
# Once a freeze window is reached, the following windows are given the spectrum
# of that window, until the freeze end is reached. The output is the same duration
# as the input.
# 
# timestep   duration of steps. Must be >= duration of 2 analysis frames.
#            (Rounded internally to a multiple of analysis-frame time.)
# 
# 
cdp.focus.add_process("step", "analfile", "analfile", None, "Step-frame, by freezing spectrum at regular time intervals.")
params = []
cdp.focus.step.add_parameters(params)
#
# HILITE
#
#
# HILITE ARPEG
#
# CDP Release 5 2005
# hilite arpeg 1-4 infile outfile wave rate [-pU] [-lX] [-hY] [-bZ] [-aA]
#                                               [-Nk] [-sS] [-T]  [-K]
# 
# hilite arpeg 5-8 infile outfile wave rate [-pU] [-lX] [-hY] [-bZ] [-aA]
# 
# MODES:-                ARPEGGIATE THE SPECTRUM
# 1 ON...........Play components inside arpeggiated band ONLY.
# 2 BOOST........Amplify snds in band. Others play unamplified.
# 3 BELOW_BOOST..INITIALLY Play components in & below band ONLY.
#                THEN amplify snds in band. Others play unamplified.
#                (NOT with downramp).
# 4 ABOVE_BOOST..INITIALLY Play components in & above band ONLY.
#                THEN amplify snds in band. Others play unamplified.
#               (NOT with upramp: with sin/saw startphase>0.5)
# 5 BELOW........Play components in & below arpeggiated band ONLY.
# 6 ABOVE........Play components in & above arpeggiated band ONLY.
# 7 ONCE_BELOW...INITIALLY Play components in and below band ONLY.
#                THEN play whole sound as normal.(NOT with downramp).
# 8 ONCE_ABOVE...INITIALLY Play components in and above arpeggiated band ONLY.
#                THEN play whole sound as normal.
#                (NOT with upramp: with sin/saw startphase>0.5)
# wave  1 downramp : 2 sin : 3 saw : 4 upramp
# rate  sweeps per second.
# -p    U = start_phase: range 0-1: (limited range for some cases).
# -l    X = lowest  freq arpeg sweeps down to: default 0
# -h    Y = highest freq arpeg sweeps up to:   default nyquist
# -b    Z = bandwidth of sweep band (in Hz): default = nyquist/channel_cnt
# -a    A = amplification of arpegtones : default 10.0
# -N    k = Nonlinear decay arpegtones. >1 faster, <1 slower. Must be >0.
# -s    S = No. of windows over which arpegtones sustained: Default 3
# -T    In sustains, TRACK changing frq of src (default : retain start frq)
# -K    Let sustains run to zero before new arpegtone attack accepted
#      (Default:Re-attack once sustains fall below current input level)
# 
# all parameters may vary over time, except for wavetype and startphase.
# 
# 
cdp.hilite.add_process("arpeg", "analfile", "analfile", 8, "Arpeggiate the spectrum.")
params = []
cdp.hilite.arpeg.add_mode(1, params, "ON")
params = []
cdp.hilite.arpeg.add_mode(2, params, "BOOST")
params = []
cdp.hilite.arpeg.add_mode(3, params, "BOOST BELOW")
params = []
cdp.hilite.arpeg.add_mode(4, params, "BOOST ABOVE")
params = []
cdp.hilite.arpeg.add_mode(5, params, "ON BELOW")
params = []
cdp.hilite.arpeg.add_mode(6, params, "ON ABOVE")
params = []
cdp.hilite.arpeg.add_mode(7, params, "ONCE BELOW")
params = []
cdp.hilite.arpeg.add_mode(8, params, "ONCE ABOVE")
#
# HILITE BAND
#
# CDP Release 5 2005
# hilite band infile outfile datafile
# 
# SPLIT SPECTRUM INTO BANDS & PROCESS THESE INDIVIDUALLY
#  
# Datafile contains a number of lines with the following info..
# 
# lofrq   hifrq   bitflag   [amp1   amp2   [+]transpose]
# 
# bitflag has 4 bits (e.g. '0101' or '1000')
# bit 1 set: amplitude change to band: put amp multiplier 'amp1' in line.
# bit 2 set: amplitude ramp: put 2nd amp multiplier 'amp2' in line.
#            (spectral band will change in amplitude from amp1 to amp2).
# bit 3 set: partials transpose: prog expects frq multiplier 'transpose' in line.
#            OR, if val preceeded by '+',val is frq in Hz ADDED to frq in band.
# bit 4 set: transposed partials ADDED to original spectrum (default: replace)
# 
# amp1, amp2 &\or transpose MUST be present, as required by the bitflag options.
# 
# 
cdp.hilite.add_process("band", "analfile", "analfile", None, "Split spectrum into bands & process these individually.")
params = []
cdp.hilite.band.add_parameters(params)
#
# HILITE BLTR
#
# CDP Release 5 2005
# hilite bltr infile outfile blurring tracing 
# 
# TIME-AVERAGE, AND TRACE, THE SPECTRUM
# 
# blurring   is number of windows over which to average the spectrum.
# tracing    is number of (loudest) channels to retain, in each window.
# 
# blurring AND tracing may vary over time. 
# 
# 
cdp.hilite.add_process("bltr", "analfile", "analfile", None, "Time-average, and trace, the spectrum.")
params = []
cdp.hilite.bltr.add_parameters(params)
#
# HILITE FILTER
#
# CDP Release 5 2005
# hilite filter 1-4   infile outfile frq1 Q 
# hilite filter 5-6   infile outfile frq1 Q gain
# hilite filter 7-10  infile outfile frq1 frq2 Q
# hilite filter 11-12 infile outfile frq1 frq2 Q gain
# 
# FILTER THE SPECTRUM
# 
# MODES:-
# 1    high pass filter 
# 2    high pass filter (normalised output) 
# 3    low pass filter 
# 4    low pass filter (normalised output) 
# 5    high pass filter with gain 
# 6    low pass filter with gain 
# 7    band pass filter 
# 8    band pass filter (normalised output) 
# 9    notch filter 
# 10   notch filter (normalised output) 
# 11   band pass filter with gain 
# 12   notch filter with gain 
# 
# frq1            filter cutoff frq.
# frq1 with frq2  limits of filter band.
# Q               width of filter skirts, in Hz (Range: >0).
# gain            amplification of resulting sound.
# 
# frq1, frq2 and Q may vary over time.
# 
# 
cdp.hilite.add_process("filter", "analfile", "analfile", 12, "Filter the spectrum.")
params = [
        ["frq1", 0, SAMPLE_RATE, "filter cutoff frq."],
        ["Q", 0, SAMPLE_RATE, "width of filter skirts, in Hz (Range: >0)."]
        ]
cdp.hilite.filter.add_mode(1, params, "HIGH PASS")
cdp.hilite.filter.add_mode(2, params, "HIGH PASS NORMALISED")
cdp.hilite.filter.add_mode(3, params, "LOW PASS")
cdp.hilite.filter.add_mode(4, params, "LOW PASS NORMALISED")
params.extend([
    ["gain", 0, None, "amplification of resulting sound."]
    ])
cdp.hilite.filter.add_mode(5, params, "HIGH PASS WITH GAIN")
cdp.hilite.filter.add_mode(6, params, "LOW PASS WITH GAIN")
params = [
        ["frq1", 0, SAMPLE_RATE, "filter cutoff frq."],
        ["frq2", 0, SAMPLE_RATE, "filter cutoff frq."],
        ["Q", 0, SAMPLE_RATE, "width of filter skirts, in Hz (Range: >0)."]
        ]
cdp.hilite.filter.add_mode(7, params, "BANDPASS")
cdp.hilite.filter.add_mode(8, params, "BANDPASS NORMALISED")
cdp.hilite.filter.add_mode(9, params, "NOTCH")
cdp.hilite.filter.add_mode(10, params, "NOTCH NORMALISED")
params.extend([
    ["gain", 0, None, "amplification of resulting sound."]
    ])
cdp.hilite.filter.add_mode(11, params, "BANDPASS WITH GAIN")
cdp.hilite.filter.add_mode(12, params, "NOTCH WITH GAIN")
#
# HILITE GREQ
#
# CDP Release 5 2005
# hilite greq mode infile outfile filtfile [-r]
# 
# GRAPHIC EQ ON SPECTRUM
# 
# MODES :-
# 1   single bandwidth for all filter bands.
#     FILTFILE has ONE bandwidth (octaves)
#     followed by centre frqs of all filter bands (Hz).
# 
# 2   separate bandwidths for each filter band.
#     FILTFILE has a pair of values for each filter band.
#     These are centre frq of the band (Hz) && bandwidth (octaves).
# 
# -r  Band reject (notch) filter: Default is a bandpass filter.
# 
# 
cdp.hilite.add_process("greq", "analfile", "analfile", 2, "Graphic eq on spectrum.")
params = []
cdp.hilite.greq.add_mode(1, params, "STANDARD BANDWIDTH")
params = []
cdp.hilite.greq.add_mode(2, params, "VARIOUS BANDWIDTHS")
#
# HILITE PLUCK
#
# CDP Release 5 2005
# hilite pluck infile outfile gain
# 
# EMPHASISE SPECTRAL CHANGES (USE e.g. WITH spec arpeg)
# 
# gain   amplitude gain applied to newly prominent spectral components.
# 
# gain may vary over time.
# 
# 
cdp.hilite.add_process("pluck", "analfile", "analfile", None, "Emphasise spectral changes (use e.g. with HILITE ARPEG).")
params = []
cdp.hilite.pluck.add_parameters(params)
#
# HILITE TRACE
#
# CDP Release 5 2005
# hilite trace 1 infile outfile N
# hilite trace 2 infile outfile N lofrq       [-r]
# hilite trace 3 infile outfile N       hifrq [-r]
# hilite trace 4 infile outfile N lofrq hifrq [-r]
# 
# RETAIN THE N LOUDEST PARTIALS ONLY (ON A WINDOW-BY-WINDOW BASIS)
# 
# MODES :-    
# 1  Select loudest spectral components.
# 2  Select loudest from above lofrq: Reject all spectral data below lofrq.
# 3  Select loudest from below hifrq: Reject all spectral data above hifrq.
# 4  Select loudest from between lofrq and hifrq: Reject data outside.
# 
# -r If trace index > no of chans in fltband (defined by lofrq\hifrq)
#    RETAIN loudest chans OUTSIDE fltband.
#    (Default: always omit chans outside fltband)
# 
# N   is number of spectral components to retain.
# 
# N, lofrq and hifrq may vary over time.
# 
# 
cdp.hilite.add_process("trace", "analfile", "analfile", 4, "Retain N loudest partials only (on window-by-window basis).")
params = []
cdp.hilite.trace.add_mode(1, params, "TRACE ALL")
params = []
cdp.hilite.trace.add_mode(2, params, "TRACE ABOVE FRQ")
params = []
cdp.hilite.trace.add_mode(3, params, "TRACE BELOW FRQ")
params = []
cdp.hilite.trace.add_mode(4, params, "TRACE BETWEEN FRQS")
#
# HILITE VOWELS
#
# CDP Release 5 2005
# hilite vowels infile outfile vowelfile halfwidth steepness range threshold
# 
# VOWELS......file containing paired times & vowels, where vowels can be....
# ee: as in 'heat'  i:  as in 'hit'    e:  as in 'pet'  ai: as in 'hate'
# a:  as in 'pat'   ar: as in 'heart'  o:  as in 'hot'  or: as in 'taught'
# oa: as in 'boat'  u:  as in 'hood'   oo: as in 'mood'
# xx: as in Southern English 'hub'     x:  neutral vowel in 'herb' or 'the'
# 
# Times must start at zero, and increase.
# 
# HALFWIDTH ....half-width of formant peaks as fraction of formant centre-frq.
#               (Range 0.01 - 10)
# STEEPNESS ....steepness of formant peaks. (Range 0.1 - 10)
# RANGE ........the peaks stand above the signal floor. The range of the peaks
# ..............is therefore a part of the total range of the signal.
# ..............Range = ratio (max) peakheight to (max) totalrange.(vals 0-1)
# THRESHOLD ....spectral window's level is compared with vowel-envelope level.
# ..............If it exceeds a certain proportion of that level,
# ..............it is forced to the vowel-envelope level.
# ..............(Otherwise it remains where it is).
# ..............threshold defines this proportion.(Range 0-1)
# good defaults might be 0.250000, 3, 0.950000, 0.5
# 
# 
cdp.hilite.add_process("vowels", "analfile", "analfile", None, "Impose vowels on a sound.")
params = []
cdp.hilite.vowels.add_parameters(params)
#
# COMBINE
#
#
# COMBINE CROSS
#
# CDP Release 5 2005
# combine cross infile infile2 outfile [-iinterp]
# 
# REPLACE SPECTRAL AMPLITUDES OF 1st FILE WITH THOSE OF 2nd.
# 
# -i	INTERP is degree of replacement.
# 
#     interp may vary over time.
# 
# 
cdp.combine.add_process("cross", "analfile", "analfile", None, "Replace channel amplitudes of 1st file with those of 2nd.")
params = []
cdp.combine.cross.add_parameters(params)
#
# COMBINE DIFF
#
# CDP Release 5 2005
# combine diff infile infile2 outfile [-ccrossover] [-a]
# 
# FIND DIFFERENCE OF TWO SPECTRA.
# 
# -c  CROSSOVER is amount of 2nd spectrum subtracted from 1st (range 0 to 1)
# -a  retains any subzero amplitudes produced (Default: sets these to zero).
# 
# crossover may vary over time.
# 
# 
cdp.combine.add_process("diff", "analfile", "analfile", None, "Find difference of two spectra.")
params = []
cdp.combine.diff.add_parameters(params)
#
# COMBINE INTERLEAVE
#
# CDP Release 5 2005
# combine interleave infile infile2 [infile3 ....] outfile leafsize
# 
# INTERLEAVE WINDOWS FROM INFILES, LEAFSIZE WINDOWS PER LEAF.
# 
# 
cdp.combine.add_process("interleave", "analfile", "analfile", None, "Interleave windows, leafsize windows per leaf.")
params = []
cdp.combine.interleave.add_parameters(params)
#
# COMBINE MAKE
#
# CDP Release 5 2005
# combine make pitchfile formantfile outfile
# 
# GENERATE SPECTRUM FROM PITCH & FORMANT DATA ONLY.
# 
# pitchfile   is a binary pitchdata file
# formantfile is a binary formantdata file
# outfile     is an analysis file which can be resynthesized with PVOC
# 
# ** Do not use output filenames which end in '1'
# 
# 
cdp.combine.add_process("make", "pitchfile", "pitchfile", None, "Generate a spectrum from only pitch & formant data.")
params = []
cdp.combine.make.add_parameters(params)
#
# COMBINE MAKE2
#
# CDP Release 5 2005
# combine make2 pitchfile formantfile envfile outfile
# 
# GENERATE SPECTRUM FROM PITCH, FORMANT AND ENVELOPE DATA ONLY.
# 
# pitchfile   is a binary pitchdata file
# formantfile is a binary formantdata file
# envfile     is a binary envelope file derived from an ANALYSIS file
# outfile     is an analysis file which can be resynthesized with PVOC
# 
# 
cdp.combine.add_process("make2", "pitchfile", "pitchfile", None, "Generate a spectrum from only pitch, formant & envelope data.")
params = []
cdp.combine.make2.add_parameters(params)
#
# COMBINE MAX
#
# CDP Release 5 2005
# combine max infile infile2 [infile3 ....] outfile
# 
# IN EACH ANALYSIS CHANNEL, IN EACH WINDOW, TAKE MAX VAL AMONGST INPUT FILES.
# 
# 
cdp.combine.add_process("max", "analfile", "analfile", None, "In each channel, in each window, keep maximum amplitude value.")
params = []
cdp.combine.max.add_parameters(params)
#
# COMBINE MEAN
#
# CDP Release 5 2005
# combine mean mode infile infile2 outfile [-llofrq] [-hhifrq] [-cchans] [-z]
# 
# GENERATE SPECTRAL 'MEAN' OF 2 SOUNDS.
# 
# LOFRQ 	is low freq limit of channels to look at.
# HIFRQ 	is high freq limit of channels to look at.
# CHANS	no. of significant channels to compare..Default: All within range.
# -z   	Zeroes channels OUTSIDE frq range specified.
# 
# MODES are...
# (1) mean channel amp of 2 files :  mean of two pitches
# (2) mean channel amp of 2 files :  mean of two frqs
# (3) channel amp from file1      :  mean of two pitches
# (4) channel amp from file1      :  mean of two frqs
# (5) channel amp from file2      :  mean of two pitches
# (6) channel amp from file2      :  mean of two frqs
# (7) max channel amp of 2 files  :  mean of two pitches
# (8) max channel amp of 2 files  :  mean of two frqs
# 
# 
cdp.combine.add_process("mean", "analfile", "analfile", 8, "Generate spectral 'mean' of 2 sounds.")
params = []
cdp.combine.mean.add_mode(1, params, "MEAN AMP & PITCH")
params = []
cdp.combine.mean.add_mode(2, params, "MEAN AMP & FRQ")
params = []
cdp.combine.mean.add_mode(3, params, "AMP FILE1: MEAN PICH")
params = []
cdp.combine.mean.add_mode(4, params, "AMP FILE1: MEAN FRQ")
params = []
cdp.combine.mean.add_mode(5, params, "AMP FILE2: MEAN PICH")
params = []
cdp.combine.mean.add_mode(6, params, "AMP FILE2: MEAN FRQ")
params = []
cdp.combine.mean.add_mode(7, params, "MAX AMP: MEAN PITCH")
params = []
cdp.combine.mean.add_mode(8, params, "MAX AMP: MEAN FRQ")
#
# COMBINE SUM
#
# CDP Release 5 2005
# combine sum infile infile2 outfile [-ccrossover]
# 
# FIND SUM OF TWO SPECTRA.
# 
# -c  CROSSOVER is amount of 2nd spectrum added to 1st (range 0 to 1)
# 
# crossover may vary over time.
# 
# 
cdp.combine.add_process("sum", "analfile", "analfile", None, "Find sum of two spectra.")
params = []
cdp.combine.sum.add_parameters(params)
#
# FORMANTS
#
#
# FORMANTS GET
#
# CDP Release 5 2005
# formants get infile outfile -fN|-pN
# 
# EXTRACT EVOLVING FORMANT ENVELOPE FROM AN ANALYSIS FILE.
# 
# OUTFILE is a formant file, which can be used in other formant applications.
# 
# -f     extract formant envelope linear frqwise,
#        using 1 point for every N equally-spaced frequency-channels.
# -p     extract formant envelope linear pitchwise,
#        using N equally-spaced pitch-bands per octave.
# 
# 
cdp.formants.add_process("get", "analfile", "analfile", None, "Extract evolving formant envelope from an analysis file.")
params = []
cdp.formants.get.add_parameters(params)
#
# FORMANTS GETSEE
#
# CDP Release 5 2005
# formants getsee infile outsndfile -fN|-pN [-s]
# 
# EXTRACT FORMANTS FROM ANALFILE AND WRITE AS 'SNDFILE' FOR VIEWING.
# 
# -f     extract formant envelope linear frqwise,
#        using 1 point for every N equally-spaced frequency-channels.
# -p     extract formant envelope linear pitchwise,
#        using N equally-spaced pitch-bands per octave.
# -s     semitone bands for display (Default: equal hz bands).
# 
# The resulting logarithmically scaled display indicates formant shapes,
# but NOT the absolute amplitude values.
# 
# (Do not use filenames which end in '1').
# 
# 
cdp.formants.add_process("getsee", "analfile", "analfile", None, "Extract formants from analysis file as 'soundfile' for viewing.")
params = []
cdp.formants.getsee.add_parameters(params)
#
# FORMANTS PUT
#
# CDP Release 5 2005
# formants put 1 infile fmntfile outfile [-i] [-llof] [-hhif] [-ggain]
# formants put 2 infile fmntfile outfile      [-llof] [-hhif] [-ggain]
# 
# IMPOSE SPECTRAL ENVELOPE IN A FORMANTFILE ON SPECTRUM IN A PVOC ANALYSIS FILE.
# 
# MODES.
# (1) New formant envelope REPLACES sound's own formant envelope.
# (2) New formant envelope IMPOSED ON TOP OF sound's own formant envelope.
# 
# INFILE and OUTFILE are PVOC analysis files. FMNTFILE is a formant data file.
# -l      LOF  = low frq,  below which spectrum is set to zero.
# -h      HIF  = high frq, above which spectrum is set to zero.
# -g      GAIN = adjustment to spectrum loudness (normally < 1.0).
# -i      quicksearch for formants (less accurate).
# 
# 
cdp.formants.add_process("put", "analfile", "analfile", 2, "Impose evolving formants from a formantfile.")
params = []
cdp.formants.put.add_mode(1, params, "REPLACE FORMANTS")
params = []
cdp.formants.put.add_mode(2, params, "SUPERIMPOSE FORMANTS")
#
# FORMANTS SEE
#
# CDP Release 5 2005
# formants see infile outsndfile [-v]
# 
# CONVERT FORMANT DATA IN A BINARY FORMANTDATA FILE TO 'SNDFILE' FOR VIEWING.
# 
# -v     display data about formant-band parameters.
# 
# The resulting logarithmically scaled display indicates formant shapes,
# but NOT the absolute amplitude values.
# 
# 
cdp.formants.add_process("see", "formantfile", "formantfile", None, "Convert formant data file to 'soundfile' for viewing.")
params = []
cdp.formants.see.add_parameters(params)
#
# FORMANTS VOCODE
#
# CDP Release 5 2005
# formants vocode infile infile2 outfile -fN|-pN [-llof] [-hhif] [-ggain]
# 
# IMPOSE SPECTRAL ENVELOPE OF 2nd SOUND, ON 1st SOUND.
# 
# -f     extract formant envelope linear frqwise,
#        using 1 point for every N equally-spaced frequency-channels.
# -p     extract formant envelope linear pitchwise,
#        using N equally-spaced pitch-bands per octave.
# -l     LOF = low frq,  below which data is filtered out.
# -h     HIF = high frq, above which data is filtered out.
# -g     GAIN adjustment to signal (normally < 1.0).
# 
# 
cdp.formants.add_process("vocode", "analfile", "analfile", None, "Impose formants extracted from 2nd sound, on 1st sound.")
params = []
cdp.formants.vocode.add_parameters(params)
#
# MORPH
#
#
# MORPH BRIDGE
#
# CDP Release 5 2005
# morph bridge mode infile1 infile2 outfile
#        [-aoffset] [-bsf2] [-csa2] [-def2] [-eea2] [-fstart] [-gend]
# 
#       MAKE A BRIDGING-INTERPOLATION BETWEEN TWO SOUND SPECTRA
# BY INTERPOLATING BETWEEN 2 TIME-SPECIFIED WINDOWS IN THE 2 INFILES.
# 
# OFFSET time infile2 starts, relative to start of file1: (>=0)  default: 0.0
# SF2    fraction of 2nd sound's frq interpolated at START.(default 0)
# SA2    fraction of 2nd sound's amp interpolated at START.(default 0)
# ...if an OFFSET is used, when SF2 or SA2 are set NON-zero,
# ...outsound starts from point where 2nd sound enters.
# EF2    fraction of 2nd sound's frq interpolated at END.(default 1)
# EA2    fraction of 2nd sound's amp interpolated at END.(default 1)
# 
# ...if EF2 or EA2 are set < 1.0 , outsound ends at end of first sound to end.
# START  time in infile1, of startwindow for interp, (secs): default: 0.0
# END    time in infile1 of endwindow of interp: default: end_of_file
# ...if START and END are not specified
# ...interp runs from OFFSET to end of 1st file to end.
# MODES....
# (1) output level is direct result of interpolation.
# (2) output level follows moment to moment minimum of the 2 infile amplitudes.
# (3) output level follows moment to moment amplitude of infile1.
# (4) output level follows moment to moment amplitude of infile2.
# (5) output level moves, through interp, from that of file1 to that of file2.
# (6) output level moves, through interp, from that of file2 to that of file1.
# 
# 
cdp.morph.add_process("bridge", "analfile", "analfile", 6, "Interpolate between two time-specified windows in two files.")
params = []
cdp.morph.bridge.add_mode(1, params, "STANDARD")
params = []
cdp.morph.bridge.add_mode(2, params, "OUTLEVEL FOLLOWS MINIMUM")
params = []
cdp.morph.bridge.add_mode(3, params, "OUTLEVEL FOLLOWS FILE1")
params = []
cdp.morph.bridge.add_mode(4, params, "OUTLEVEL FOLLOWS FILE2")
params = []
cdp.morph.bridge.add_mode(5, params, "OUTLEVEL MOVES FROM 1 TO 2")
params = []
cdp.morph.bridge.add_mode(6, params, "OUTLEVEL MOVES FROM 2 TO 1")
#
# MORPH GLIDE
#
# CDP Release 5 2005
# morph glide infile infile2 outfile duration
# 
# INTERPOLATE, LINEARLY, BETWEEN 2 SINGLE ANALYSIS WINDOWS
#               EXTRACTED WITH spec grab.
# 
# INFILE1, INFILE2  are single-window analysis files.
# DURATION          is duration of output sound required.
# 
# 
cdp.morph.add_process("glide", "analfile", "analfile", None, "Interpolate, linearly, between 2 single analysis windows")
params = []
cdp.morph.glide.add_parameters(params)
#
# MORPH MORPH
#
# CDP Release 5 2005
# morph morph mode infile infile2 outfile as ae fs fe expa expf [-sstagger]
# 
# MORPH ONE SPECTRUM INTO ANOTHER.
# 
# as   is time(secs) when amplitude-interpolation starts.
# ae   is time(secs) when amplitude-interpolation ends.
# fs   is time(secs) when frequency-interpolation starts.
# fe   is time(secs) when frequency-interpolation ends.
# expa is exponent of amplitude interpolation.
# expf is exponent of frequency interpolation.
# stagger is time-delay of entry of 2nd file (defalut 0.0).
# 
# MODES..
# (1) interpolate linearly (exp 1)
#     or over a curve of increasing (exp >1) or decreasing (exp <1) slope.
# (2) interpolate over a cosinusoidal spline.
# 
# 
cdp.morph.add_process("morph", "analfile", "analfile", 2, "Morph one spectrum into another.")
params = []
cdp.morph.morph.add_mode(1, params, "LINEAR OR CURVED")
params = []
cdp.morph.morph.add_mode(2, params, "COSINUSOIDAL")
#
# MODIFY
#
#
# MODIFY BRASSAGE
#
# CDP Release 5 2005
# GRANULAR RECONSTITUTION OF SOUNDFILE
# 
# MODES ARE...
# 1) PITCHSHIFT      4) SCRAMBLE
# 2) TIMESTRETCH     5) GRANULATE
# 3) REVERB          6) BRASSAGE
#                    7) FULL MONTY
# USAGE  (name of outfile must NOT end with a '1')
# modify brassage 1 infile outfile pitchshift
# modify brassage 2 infile outfile velocity
# modify brassage 3 infile outfile density pitch amp [-rrange]
# modify brassage 4 infile outfile grainsize [-rrange]
# modify brassage 5 infile outfile density [-d]
# 
# modify brassage 6 infile outfile velocity density grainsize pitchshft amp space
#           bsplice esplice
#           [-rrange] [-jjitter] [-loutlength] [-cchannel] [-d] [-x] [-n]
# 
# modify brassage 7 infile outfile velocity density hvelocity hdensity
#           grainsize  pitchshift  amp  space  bsplice  esplice
#           hgrainsize hpitchshift hamp hspace hbsplice hesplice
#           [-rrange] [-jjitter] [-loutlength] [-cchannel] [-d] [-x] [-n]
# 
# 
# VELOCITY:  speed of advance in infile, relative to outfile. (>=0)
#            This is inverse of timestretch, (& permits infinite timestretch).
# DENSITY:   amount of grain overlap (>0 : <1 leaves intergrain silence)
#            Extremely small values will cease to perform predictably.
# GRAINSIZE: grainsize in MS (must be > 2 * splicelen) (Default 50)
# PITCHSHIFT:is pitchshift in +|- (fractions of) semitones.
# AMP:       is gain on grains (range 0-1)             (Default 1.0)
#            use only if you want amp to vary (over a range &/or in time)
# BSPLICE:   length of startsplices on grains,in MS (Default 5)
# ESPLICE:   length of endsplices   on grains,in MS (Default 5)
# SPACE:     set stereo position in outputfile. 0=L,1=R    (Range 0-1).
#            Space flag on STEREO input, mixes it to mono before acting.
# RANGE:     of search for nextgrain, before infile 'now'  (Default 0 MS).
# JITTER:    Randomisation of grain position (Range 0-1) Default (0.50).
# OUTLENGTH: maximum outfile length (if end of data not reached).
#            Set to zero (Default) for this parameter to be ignored.
#            BUT if VELOCITY is ANYWHERE 0: OUTLENGTH must be given.
# CHANNEL    Extract & work on just 1 channel of stereo snd: Range(1-2).
#            Set to zero (Default) for this parameter to be ignored.
# -x:        do exponential splices           (Default: linear).
# -n:        no interpolation for pitch vals, (quick but dirty).
# 
# HVELOCITY,HDENSITY,HGRAINSIZE,HPITCHSHIFT,HAMP,HBSPLICE,HESPLICE,HSPACE
# allow a range of values to be specified for any of these params. e.g. With
# PITCHSHIFT & HPITCHSHIFT set, random pitchshift chosen between these limits.
# AND NB PITCHSHIFT & HPITCHSHIFT can both vary through time.
# 
# All params, except OUTLENGTH and CHANNEL, can vary through time.
# 
# 

cdp.modify.add_process("brassage", "-", "-", 7, "GRANULAR RECONSTITUTION OF SOUNDFILE")

params = [["pitchshift", None, None, "is pitchshift in +|- (fractions of) semitones."]]
cdp.modify.brassage.add_mode(1, params, "PITCHSHIFT")

params = [["velocity", 0, None, "speed of advance in infile, relative to outfile. (>=0)\nThis is inverse of timestretch, (& permits infinite timestretch)."]]
cdp.modify.brassage.add_mode(2, params, "TIMESTRETCH")

params = [["density", 0, 1, "amount of grain overlap (>0 : <1 leaves intergrain silence)\nExtremely small values will cease to perform predictably."],
        ["pitch", None, None],
        ["amp", 0, 1, "gain on grains\nuse only if you want amp to vary (over a range &/or in time)"],
        ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."]]
cdp.modify.brassage.add_mode(3, params, "REVERB")

params = [["grainsize", 50, 50, "grainsize in MS (must be > 2 * splicelen) (Default 50)"],
        ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."]]
cdp.modify.brassage.add_mode(4, params, "SCRAMBLE")

params = [["density", 0, 1, "amount of grain overlap (>0 : <1 leaves intergrain silence)\nExtremely small values will cease to perform predictably."]]
cdp.modify.brassage.add_mode(5, params, "GRANULATE")

br_params = [["velocity", 0, None],
        ["density", 0, 1],
        ["grainsize", 50, 50],
        ["pitchshift", None, None],
        ["amp", 0, 1],
        ["space", 0, 1, "set stereo position in outputfile. 0=L,1=R    (Range 0-1).\nSpace flag on STEREO input, mixes it to mono before acting."],
        ["bsplice", 0, None, "length of startsplices on grains,in MS (Default 5)"],
        ["esplice", 0, None, "length of endsplices on grains,in MS (Default 5)"],
        ]
params = br_params
params.extend([
    ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."],
    ["-j", 0, 1, "jitter"],
    ["-l", 0, None, "outlength"],
    ["-c", 0, 2, "Extract & work on just 1 channel of stereo snd: Range(1-2)."],
    ["-x", None, None, "do exponential splices."],
    ["-n", None, None, "no interpolation for pitch vals."] ])
cdp.modify.brassage.add_mode(6, params, "BRASSAGE")

params = br_params
params.extend([["hvelocity", 0, None],
    ["hdensity", 0, 1, "high density"],
    ["hgrainsize", 50, 50, "high grainsize"],
    ["hpitchshift", None, None, "high pitchshift"],
    ["hamp", 0, 1, "high amp"],
    ["hspace", 0, 1, "(high) set stereo position in outputfile. 0=L,1=R    (Range 0-1).\nSpace flag on STEREO input, mixes it to mono before acting."],
    ["hbsplice", 0, None, "(high) length of startsplices on grains,in MS (Default 5)"],
    ["hesplice", 0, None, "(high) length of endsplices on grains,in MS (Default 5)"],
    ["-r", 0, None, "of search for nextgrain, before infile 'now'  (Default 0 MS)."],
    ["-j", 0, 1, "jitter"],
    ["-l", 0, None, "outlength"],
    ["-c", 0, 2, "Extract & work on just 1 channel of stereo snd: Range(1-2)."],
    ["-x", None, None, "do exponential splices."],
    ["-n", None, None, "no interpolation for pitch vals."]])
cdp.modify.brassage.add_mode(7, params, "FULL MONTY")

#
# MODIFY FINDPAN
#
# CDP Release 5 2005
# FIND STEREO-PAN POSITION OF A SOUND IN A STEREO FILE
# 
# USAGE: modify findpan infile time
# 
# Process assumes file contains a sound which has previously been panned to a position
# in the stereo field. The process will give misleading results if this is not the case.
# 
# 
cdp.modify.add_process("findpan", "sndfile", "sndfile", None, "Find stereo-pan position of a sound in a stereo file.")
params = []
cdp.modify.findpan.add_parameters(params)
#
# MODIFY LOUDNESS
#
# CDP Release 5 2005
# ADJUST LOUDNESS OF A SOUNDFILE
# 
# USAGE: modify loudness 1 infile         outfile gain
# OR:    modify loudness 11-12 infile     outfile gain
# OR:    modify loudness 2 infile         outfile gain
# OR:    modify loudness 3 infile         outfile [-llevel]
# OR:    modify loudness 4 infile         outfile [-llevel]
# OR:    modify loudness 5 infile infile2 outfile
# OR:    modify loudness 6 infile outfile
# OR:    modify loudness 7 infile infile2 etc.
# OR:    modify loudness 8 infile infile2 etc. outfile
# 
# WHERE MODES ARE
# 1) GAIN:         adjust level by factor GAIN.
# 2) dBGAIN:       adjust level by GAIN dB. Range +-96.0
# 3) NORMALISE:    force level (if ness) to max possible, or to LEVEL given.
# 4) FORCE LEVEL:  force level to maximum possible, or to LEVEL given.
# 5) BALANCE:      force max level of file1 to max level of file 2.
# 6) INVERT PHASE: Invert phase of the sound.
# 7) FIND LOUDEST: find loudest file.
# 8) EQUALISE:     force all files to level of loudest file.
# 11) PROPORTIONAL:    adjust level with envelope stretched to dur of sound.
# 12) PROPORTIONAL dB: adjust level with dB envelope stretched to dur of sound.
#                  Infiles are rescaled in input order, with output names as
#                  outfile0, outfile1, outfile2, outfile3 etc.
# 
# 
cdp.modify.add_process("loudness", "sndfile", "sndfile", 12, "Alter loudness or balance of sound.")
params = [["gain", 0, 100.0, "adjust level by factor GAIN"]] # TODO: Unsure of upper limit.
cdp.modify.loudness.add_mode(1, params, "GAIN")
params = [["gain", -96.0, 96.0, "adjust level by factor GAIN"]]
cdp.modify.loudness.add_mode(2, params, "DB GAIN")
params = [["-l", 0.0,1.0, "level"]]
cdp.modify.loudness.add_mode(3, params, "NORMALISE")
params = [["-l", 0.0,1.0, "level"]]
cdp.modify.loudness.add_mode(4, params, "SET LEVEL")
params = []
cdp.modify.loudness.add_mode(5, params, "BALANCE SRCS")
params = []
cdp.modify.loudness.add_mode(6, params, "INVERT PHASE")
params = []
cdp.modify.loudness.add_mode(7, params, "FIND LOUDEST")
params = []
cdp.modify.loudness.add_mode(8, params, "EQUALISE")
#
# MODIFY RADICAL
#
# CDP Release 5 2005
# RADICAL CHANGES TO THE SOUND.
# 
# USAGE: modify radical 1 infile outfile
# OR:    modify radical 2 infile outfile repeats chunklen [-sscatter]
# OR:    modify radical 3 infile outfile dur [-ldown] [-hup] [-sstart] [-eend]
# OR:    modify radical 4 infile outfile  bit_resolution  srate_division
# OR:    modify radical 5 infile outfile  modulating-frq
# OR:    modify radical 6 infile1 infile2 outfile
# 
# MODES ARE
# 1) REVERSE:         sound plays backwards.
# 2) SHRED:           sound is shredded, within its existing duration.
#                     REPEATS   no. of repeats of shredding process.
#                     CHUNKLEN  average length of chunks to cut & permute.
#                     SCATTER   randomisation of cuts (0 to K): default 1.
#                     where K = total no. of chunks (snd-duration/chunklen).
#                     If scatter = 0, reorders without shredding.
#                     NB:  chunklen * scatter MUST be < program's snd buffer.
#                     NB2: If Input sound > internal buffer len,
#                     each buffer of sound shredded independently.
# 3) SCRUB BACK & FORTH: as if handwinding over a tape-head.
#                     DUR       is minimum length of outfile required.
#                     DOWN      is lowest downward transposition (semitones).
#                     UP        is highest upward transposition (semitones).
#                     START     scrubs starts before time 'start' secs.
#                     END       scrubs end after time 'end' secs.
# 4) LOSE RESOLUTION: sound converted to lower srate, or bit-resolution.
#                     BIT_RESOLUTION  range(1 - 16): default 16-bit.
#                     SRATE_DIVISION  range(1-256): default 1 (normal)
#                     entered value will be rounded to a power of 2.
#                     Works on MONO FILES ONLY.
# 5) RING MODULATE:   against input modulating frequency, creating sidebands.
# 6) CROSS MODULATE:  Two infiles are multiplied, creating complex sidebands.
# 
# 
cdp.modify.add_process("radical", "sndfile", "sndfile", 6, "Radically modify the source sound.")

# REVERSE

cdp.modify.radical.add_mode(1, None, "REVERSE")

# SHRED

params = [  ["repeats", 0, None, "no. of repeats of shredding process"],
            ["chunklen", 0, None, "Average length of chunks to cut & permute."],
            ["-s", 0, None, "SCATTER. Randomisation of cuts (0 to K): default 1. If scatter = 0, reorders without shredding."]]

cdp.modify.radical.add_mode(2, params, "SHRED")

# SCRUB BACK & FORTH

params = [  ["dur", 0, None, "minimum length of outfile required"],
            ["-l", None, None, "lowest downward transposition (semitones)."],
            ["-h", None, None, "highest upward transposition (semitones)."],
            ["-s", 0, None, "scrubs start before time 'start' secs."],
            ["-e", 0, None, "scrubs end after time 'end' secs."]]

cdp.modify.radical.add_mode(3, params, "SCRUB BACK & FORTH")
params = [
        ["bit_resolution", 1, 16, "BIT RESOLUTION range(1 - 16): default 16-bit"],
        ["srate_division", 1, 256, "SRATE_DIVISION range(1 - 256): default 1 (normal)"]
        ]
cdp.modify.radical.add_mode(4, params, "LOWER RESOLUTION")
params = [
        ["modulating-frq", 1, 22050, "modulate against input frequency, creating sidebands"]
        ]
cdp.modify.radical.add_mode(5, params, "RING MODULATE")
params = [
        ["outfile", 1, 22050, "two infiles are multiplied, creating complex sidebands*"]
        ]
cdp.modify.radical.add_mode(6, params, "CROSS MODULATE")
#
# MODIFY REVECHO
#
# CDP Release 5 2005
# CREATE REVERB, ECHO, OR RESONANCE AROUND SOUND
# 
# USAGE: modify revecho 1 infl outfl delay mix feedback tail [-pprescale] [-i]
# OR:    modify revecho 2 infl outfl delay mix feedback
#                                    lfomod lfofreq lfophase lfodelay
#                                    tail [-pprescale] [-sseed]
# OR:    modify revecho 3 infl outfl [-ggain] [-rroll_off] [-ssize] [-ecount]
# 
# WHERE MODES ARE
# 1) STANDARD DELAY with feedback, & mix (0=dry) of original & delayed signal.
# 2) VARYING DELAY  with low frequency oscillator varying delay time.
# 3) STADIUM ECHO   create stadium P.A. type echos.
# 
# DELAY     Delay time, in milliseconds.
# MIX       amount of delayed signal in final mix: 0 gives 'dry' result.
# FEEDBACK  produces resonance related to delay time (with short times).
# TAIL      is time to allow delayed signal to decay to zero.
# PRESCALE  prescales input level, to avoid overload.
# -i        inverts the dry signal (for phasing effects).
# LFOMOD    is the depth of delay-variation sweep.
# LFOFREQ   is the freq of the sweep: -ve vals give random oscillations.
# LFOPHASE  is the start phase of the sweep.
# LFODELAY  is the time before the seep begins.
# SEED      Nonzero value gives reproducible output (with same seed)
#           where random oscillations are used.
# GAIN      to apply to input signal: Default is 0.645654
# SIZE      multiplies average time between echoes: (Default time 0.1 secs).
# ROLL_OFF  rate of loss of level across stadium (default 1)
# COUNT     number of stadium echoes: Default (max) is 1000
# 
# 
cdp.modify.add_process("revecho", "sndfile", "sndfile", 3, "Add reverberation or echo to the sound.")
params = []
cdp.modify.revecho.add_mode(1, params, "DELAY")
params = []
cdp.modify.revecho.add_mode(2, params, "VARYING DELAY")
params = []
cdp.modify.revecho.add_mode(3, params, "STADIUM")
#
# MODIFY SAUSAGE
#
# CDP Release 5 2005
# GRANULAR RECONSTITUTION OF SEVERAL SOUNDFILES SCRAMBLED TOGETHER.
# 
# USAGE       (name of outfile must NOT end with a '1')
# modify sausage infile [infile2 ...] outfile velocity density
#   hvelocity hdensity grainsize  pitchshift  amp  space  bsplice  esplice
#   hgrainsize hpitchshift hamp hspace hbsplice hesplice
#   [-rrange] [-jjitter] [-loutlength] [-cchannel] [-d] [-x] [-n]
# 
# VELOCITY:  speed of advance in infiles, relative to outfile. (>=0)
#            inverse of timestretch, (permits infinite timestretch).
# DENSITY:   grain overlap (>0 : <1 leaves intergrain silence)
#            Extremely small values don't perform predictably.
# GRAINSIZE: grainsize in MS (must be > 2 * splicelen) (Default 50)
# PITCHSHIFT:pitchshift in +|- (fractions of) semitones.
# AMP:       gain on grains (range 0-1) (Default 1.0)
#            use if amp variation required (over a range &/or in time)
# BSPLICE:   grain-startsplice length,in MS (Default 5)
# ESPLICE:   grain-endsplice length,in MS (Default 5)
# SPACE:     stereo position in outputfile. 0=L,1=R    (Range 0-1).
#            Space flag on STEREO input, mixes to mono before acting.
# RANGE:     of search for nextgrain, before infile 'now'  (Default 0 MS).
# JITTER:    Randomisation of grain position (Range 0-1) Default (0.50).
# OUTLENGTH: max outfile length (if end of data not reached).
#            Set to zero (Default) to ignore.
#            BUT if VELOCITY is ANYWHERE 0: OUTLENGTH must be given.
# CHANNEL:   work on just 1 channel of stereo snd: Range(1-2).
#            Set to zero (Default) to ignore.
# -x:        do exponential splices           (Default: linear).
# -n:        no interpolation for pitch vals, (quick but dirty).
# 
# HVELOCITY,HDENSITY,HGRAINSIZE,HPITCHSHIFT,HAMP,HBSPLICE,HESPLICE,HSPACE
# allow a range of values to be specified for any of these params. e.g. With
# PITCHSHIFT & HPITCHSHIFT set, random pitchshift chosen between these limits.
# AND NB PITCHSHIFT & HPITCHSHIFT can both vary through time.
# 
# All params, except OUTLENGTH and CHANNEL, can vary through time.
# 
# 
cdp.modify.add_process("sausage", "sndfile", "sndfile", None, "Brassage on several sources.")
params = []
cdp.modify.sausage.add_parameters(params)
#
# MODIFY SCALEDPAN
#
# CDP Release 5 2005
# DISTRIBUTE SOUND IN STEREO SPACE, SCALING PAN DATA TO SNDFILE DURATION
# 
# USAGE: modify scaledpan infile outfile pan [-pprescale]
# 
# PAN      breakpoint file of time, position pairs.
#          Positions sound in a stereo field, from -1 (Left) to 1 (Right) or beyond.
# PRESCALE reduces input level to avoid clipping (default 0.7)
# 
# 
cdp.modify.add_process("scaledpan", "sndfile", "sndfile", None, "Distribute sound in stereo space, scaling pan data to soundfile duration.")
params = []
cdp.modify.scaledpan.add_parameters(params)
#
# MODIFY SHUDDER
#
# CDP Release 5 2005
# SHUDDER A STEREO FILE
# 
# USAGE: modify shudder infile outfile
#          starttime  frq  scatter  stereo_spread  mindepth  maxdepth  minwidth  maxwidth
# 
# START_TIME    is time when Shuddering will begin.
# FREQUENCY     is (average) frequency of the shuddering.
# SCATTER       randomises the shudder events, in time. (0 - 1)
# STEREO_SPREAD positions the shudder events in space. (0 - 1)
# DEPTH         amplitude of shudders (each gets randval btwn MIN & MAX) Range 0-1
# EVENT WIDTH   durations of shudder events (each gets randval btwn MIN & MAX)
# 
# Name of outfile must NOT end with a '1'
# 
# 
cdp.modify.add_process("shudder", "sndfile", "sndfile", None, "Shudder a stereo file.")
params = [
        ["starttime", 0, None, "time when Shuddering will begin."],
        ["frq", 0, 22050, "(average) frequency of the shuddering."],
        ["scatter", 0, 1, "randomises the shudder events, in time. (0 - 1)"],
        ["stereo_spread", 0, 1, "positions the shudder events in space."],
        ["mindepth", 0, 1, "amplitude of shudders (each gets randval btwn MIN & MAX) Range 0-1"],
        ["maxdepth", 0, 1, "amplitude of shudders (each gets randval btwn MIN & MAX) Range 0-1"],
        ["minwidth", 0, 1, "durations of shudder events (each gets randval btwn MIN & MAX)"],
        ["maxwidth", 0, 1, "durations of shudder events (each gets randval btwn MIN & MAX)"]
        ]
cdp.modify.shudder.add_parameters(params)
#
# MODIFY SPACE
#
# CDP Release 5 2005
# CREATE OR ALTER DISTRIBUTION OF SOUND IN STEREO SPACE
# 
# USAGE: modify space 1 infile outfile pan [-pprescale]
# OR:    modify space 2 infile outfile
# OR:    modify space 3 infile outfile
# OR:    modify space 4 infile outfile narrowing
# 
# WHERE MODES ARE
# 1) PAN:         Position or move mono sound in a stereo field.
#                 Prescale reduces inlevel to avoid clipping (default 0.7)
# 2) MIRROR:      Invert stereo positions in a stereo file.
# 3) MIRRORPAN:   Invert stereo positions in a pan data file.
# 4) NARROW:      Narrow the stereo image of a sound.
#                 NARROWING range, -1 to 1
#                 1   leaves stereo image as it is.
#                 .5  narrows stereo image by half.
#                 0   converts stereo image to mono.
#                 -ve vals work similarly, but also invert stereo image.
# 
# 
cdp.modify.add_process("space", "sndfile", "sndfile", 4, "Spatialise, or alter spatialisation of, sound.")
params = []
cdp.modify.space.add_mode(1, params, "PAN")
#
# MODIFY SPACEFORM
#
# CDP Release 5 2005
# CREATE A SINUSOIDAL SPATIAL DISTRIBUTION DATA FILE
# 
# USAGE: modify spaceform outpanfile cyclelen width dur quantisation phase
# 
# CYCLELEN     is the duration of one complete sinusoidal pan cycle
# WIDTH        is the width of the pan (from 0 to full width,1)
# DUR          is the duration of the output file.
# QUANTISATION is time step between successive space-position specifications.
# PHASE        is the angular position at which the pan starts.
#              0 is full left, 360 is full right.
# cyclelen and width may vary over time
# 
# 
cdp.modify.add_process("spaceform", "sndfile", "sndfile", None, "Create a sinusoidal spatial distribution data file.")
params = []
cdp.modify.spaceform.add_parameters(params)
#
# MODIFY SPEED
#
# CDP Release 5 2005
# CHANGE THE SPEED & PITCH OF THE SRC SOUND.
# 
# USAGE: modify speed 1 infile outfile     speed             [-o]
# OR:    modify speed 2 infile outfile     semitone-transpos [-o]
# OR:    modify speed 3 infile outtextfile speed             [-o]
# OR:    modify speed 4 infile outtextfile semitone-transpos [-o]
# OR:    modify speed 5 infile outfile     accel  goaltime   [-sstarttime]
# OR:    modify speed 6 infile outfile    vibrate vibdepth
# WHERE MODES ARE
# 1)  Vary speed/pitch of a sound.
# 2)  Vary speed/pitch by constant (fractional) no. of semitones.
# 3)  Get information on varying speed in a time-changing manner.
# 4)  Get info on time-variable speedchange in semitones.
#     -o  brkpnt times read as outfile times (default: as infile times).
# 5)  Accelerate or decelerate a sound.
#     ACCEL:     multiplication of speed reached by GOALTIME.
#     GOALTIME:  time in OUTPUT file at which accelerated speed reached.
#                If infile not exhausted there, it continues to accel.
#                If insound finishes before GOALTIME reached,
#                outfile won't reach specified acceleration value.
#     STARTTIME: time in input/output file at which accel begins.
# 6)  Add vibrato to a sound.
#     VIBRATE:   is rate of vibrato shaking in cycles-per-second.
#     VIBDEPTH:  is vibrato depth in (possibly fractional) semitones.
#     both of these may vary in time.
# 
# 
cdp.modify.add_process("speed", "sndfile", "sndfile", 6, "Change speed (& pitch) of sound. (also see BRASSAGE,& REPITCH MENU).")
params = []
cdp.modify.speed.add_mode(1, params, "SPEED CHANGE")
params = []
cdp.modify.speed.add_mode(2, params, "SPEED CHANGE IN SEMITONES")
params = []
cdp.modify.speed.add_mode(3, params, "VARISPEED INFO")
params = []
cdp.modify.speed.add_mode(4, params, "VARISPEED INFO (IN SEMITONES)")
params = []
cdp.modify.speed.add_mode(5, params, "ACCELERATE")
params = []
cdp.modify.speed.add_mode(6, params, "VIBRATO")
#
# MODIFY STACK
#
# CDP Release 5 2005
# CREATE A MIX WHICH STACKS TRANPOSED VERSIONS OF SOURCE ON ONE ANOTHER
# 
# USAGE: modify stack infile outfile transpos count lean atk-offset gain dur [-s]
# 
# TRANSPOS   when numeric, is (semitone) transposition between successive copies
#            or (as a file) a set of transposition values for each stack component.
# COUNT      is the number of copies in the stack.
# LEAN       is the loudness of the highest component, relative to the lowest.
# ATK_OFFSET is time at which attack of sound occurs.
# GAIN       is an overall amplifying factor on the ouptut sound.
# DUR        how much of the output to make (a proportion, from 0 to 1).
# -s         see the relative levels of the layers in the stack
# 
# 
cdp.modify.add_process("stack", "sndfile", "sndfile", None, "Create a mix that stacks transposed versions of the source on top of one another.")
params = []
cdp.modify.stack.add_parameters(params)
#
# PITCH
#
#
# PITCH ALTHARMS
#
# CDP Release 5 2005
# pitch altharms mode infile pitchfile outfile [-x]
# 
# DELETE ALTERNATE HARMONICS
# 
# MODES :-
# 1   delete odd harmonics.
#     Usually produces octave up transposition with no formant change.
# 2   delete even harmonics.
# -x  alternative spectral reconstruction.
# 
# PITCHFILE must be derived from infile
# 
# 
cdp.pitch.add_process("altharms", "analfile", "analfile", 2, "Delete alternate harmonics.")
params = []
cdp.pitch.altharms.add_mode(1, params, "DELETE ODD HARMONICS")
params = []
cdp.pitch.altharms.add_mode(2, params, "DELETE EVEN HARMONICS")
#
# PITCH CHORD
#
# CDP Release 5 2005
# pitch chord infile outfile transpose_file [-bbot] [-ttop] [-x]
# 
# TRANSPOSED VERSIONS OF SOUND SUPERIMPOSED ON ORIGINAL
# 
# transpose_file is file of (possibly fractional) semitone transposition values.
# 
# -t   TOP = top frq, above which data is filtered out.
# -b   BOT = bottom frq, below which data is filtered out.
# -x   Fuller spectrum.
# 
# top frq and bottom frq may vary over time.
# 
# 
# 
cdp.pitch.add_process("chord", "analfile", "analfile", None, "Transposed spectra mixed.")
params = []
cdp.pitch.chord.add_parameters(params)
#
# PITCH CHORDF
#
# CDP Release 5 2005
# pitch chordf infile outfile -fN|-pN [-i] transpose_file [-bbot] [-ttop] [-x]
# 
# TRANSPOSED VERSIONS OF SPECTRUM SUPERIMPOSED WITHIN EXISTING SPECTRAL ENVELOPE
# 
# -f   extract spectral envelope linear-freqwise, using N chans per point.
# -p   extract spectral envelope linear-pitchwise, using N bands per octave.
#      (recommeded value 1.0)
# -i   quicksearch for formants (less accurate).
# 
# transpose_file is file of (possibly fractional) semitone transposition values.
# 
# -b   BOT = bottom frq, below which data is filtered out.
# -t   TOP = top frq, above which data is filtered out.
# -x   Fuller spectrum.
# 
# top frq and bottom frq may vary over time.
# 
# 
# 
cdp.pitch.add_process("chordf", "analfile", "analfile", None, "Transposed spectra mixed inside original spectral envelope.")
params = []
cdp.pitch.chordf.add_parameters(params)
#
# PITCH OCTMOVE
#
# CDP Release 5 2005
# pitch octmove 1-2 infile pitchfile outfile [-i] transposition
# pitch octmove 3   infile pitchfile outfile [-i] transposition bassboost
# 
# OCTAVE TRANSPOSE WITHOUT FORMANT SHIFT
# 
# MODES :-
# 1   transpose up.
# 2   transpose down.
# 3   transpose down, with bass-reinforcement.
# 
# PITCHFILE must be derived from infile.
# transposition an integer transposition-ratio: 2 is 8va, 3 is 12th etc.
#               as in harmonic series.
# bassboost     bass reinforcement: values >=0.0
# -i            quicksearch for formants (less accurate).
# 
# bassboost may vary over time.
# 
# 
cdp.pitch.add_process("octmove", "analfile", "analfile", 3, "Octave transpose without formant shift.")
params = []
cdp.pitch.octmove.add_mode(1, params, "UP")
params = []
cdp.pitch.octmove.add_mode(2, params, "DOWN")
params = []
cdp.pitch.octmove.add_mode(3, params, "DOWN WITH BASS BOOST")
#
# PITCH PICK
#
# CDP Release 5 2005
# pitch pick 1-3 infile outfile fundamental         [-cclarity]
# pitch pick 4-5 infile outfile fundamental frqstep [-cclarity]
# 
# ONLY RETAIN CHANNELS WHICH MIGHT HOLD SPECIFIED PARTIALS
# 
# MODES :-
# 1   Harmonic Series.
# 2   Octaves.
# 3   Odd partials of harmonic series only.
# 4   Partials are successive linear steps (each of frqstep) from 'fundamental'.
# 5   Add linear displacement (frqstep) to harmonic partials over fundamental.
# 
# fundamental  Fundamental frequency of harmonic series, (or of calculation).
# frqstep      Frequency step to be added to another frequency.
# clarity      extent to which data in other channels is suppressed.
#              Range 0-1: Default 1.
# 
# clarity may vary over time.
# 
# 
cdp.pitch.add_process("pick", "analfile", "analfile", 5, "Retain only channels which might hold specified partials.")
params = []
cdp.pitch.pick.add_mode(1, params, "HARMONIC SERIES")
params = []
cdp.pitch.pick.add_mode(2, params, "OCTAVES")
params = []
cdp.pitch.pick.add_mode(3, params, "ODD HARMONICS ONLY")
params = []
cdp.pitch.pick.add_mode(4, params, "LINEAR FRQ STEPS")
params = []
cdp.pitch.pick.add_mode(5, params, "DISPLACED HARMONICS")
#
# PITCH TRANSP
#
# CDP Release 5 2005
# pitch transp 1-3 infile outfile frq_split                     [-ddepth]
# pitch transp 4-5 infile outfile frq_split transpos            [-ddepth]
# pitch transp 6   infile outfile frq_split transpos1 transpos2 [-ddepth]
# 
# SHIFT PITCH OF (PART OF) SPECTRUM
# 
# MODES :-
# 1   Octave transpose up, above freq_split.
# 2   Octave transpose down, below freq_split.
# 3   Octave transpose up and down.
# 4   Pitch  transpose up, above freq_split.
# 5   Pitch  transpose down, below freq_split.
# 6   Pitch  transpose up and down.
# 
# frq_split is frequency above or below which transposition takes place.
# transpos  is transposition above or below freq_split.
# transpos1 is transposition above freq_split. (semitones)
# transpos2 is transposition below freq_split. (semitones)
# depth     transposition effect on source (from 0(no effect) to 1(full effect))
# 
# depth,frq_split,transpos1 & transpos2 can vary over time.
# 
# 
cdp.pitch.add_process("transp", "analfile", "analfile", 6, "Transpose pitch of (part of) spectrum, keeping harmonic relationships.")
params = []
cdp.pitch.transp.add_mode(1, params, "8VA SHIFT UP")
params = []
cdp.pitch.transp.add_mode(2, params, "8VA SHIFT DOWN")
params = []
cdp.pitch.transp.add_mode(3, params, "8VA SHIFT UP AND DOWN")
params = []
cdp.pitch.transp.add_mode(4, params, "SHIFT UP")
params = []
cdp.pitch.transp.add_mode(5, params, "SHIFT DOWN")
params = []
cdp.pitch.transp.add_mode(6, params, "SHIFT UP AND DOWN")
#
# PITCH TUNE
#
# CDP Release 5 2005
# pitch tune mode infile outfile pitch_template
#                [-ffocus] [-cclarity] [-ttrace] [-bbcut] 
# 
# REPLACE SPECTRAL FRQS BY HARMONICS OF SPECIFIED PITCH(ES)
# 
# MODES :-
# 1   enter pitch_template data as frq (in Hz).
# 2   enter pitch_template data as (possibly fractional) MIDI values.
# 
# pitch_template   a value, or a textfile containing values (as hz or midi).
# 
# -f  FOCUS determines degree of focusing of partial pitches onto template.
#     (range 0-1: val or brkpnt file: default 1).
# -c  CLARITY determines degree to which non-template partials are suppressed.
#     (range 0-1: val or brkpnt file: default 0).
# -t  TRACE specifies no. of (window_by_window) most prominent channels
#     to be replaced by template frqs.
# -b  Ignore frqs below BCUT, Bass cutoff frq.
# 
# All parameters may vary over time.
# 
# 
cdp.pitch.add_process("tune", "analfile", "analfile", 2, "Replace spectral frequencies by harmonics of specified pitch(es).")
params = []
cdp.pitch.tune.add_mode(1, params, "TUNINGS AS FRQS")
params = []
cdp.pitch.tune.add_mode(2, params, "TUNINGS AS MIDI")
#
# PSOW
#
#
# PSOW CHOP
#
# USAGE:
# psow chop infile outfile pitch-brkpnt-data time-grain-pairs
# 
# Chop sound into sections between specified grain(chunks)
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# TIME-GRAIN-PAIRS   File contains pairs of values: time   graincnt.
#                    'Time' is time of grain where file is cut.
#                    File is always cut at start-of-grain boundary.
#                    Next segment begins AFTER the specified grainchunk.
#                    'Graincnt' is no. of grains in chunk, at specified time,
#                    before the next cut-section starts.
# 
# This process might be used in conjunction with 'psow grab' or 'interp',
# Grabbing a grain at a particular time in the sound, extending it,
# then reinserting it into the original sound by using the chopped components.
# 
cdp.psow.add_process("chop", "sndfile", "sndfile", None, "Chop soundfile into sections between specified grain-chunks.")
params = []
cdp.psow.chop.add_parameters(params)
#
# PSOW CUTATGRAIN
#
# USAGE:
# psow cutatgrain 1-2 infil outfil pitch-brkpnt-data time
# 
# Cuts the file at the specified time.
# Mode 1: Retains file BEFORE (exact) specified grain time.
# Mode 2: Retains file AT AND AFTER (exact) specified grain.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# GRAIN-NO       time at which to cut the file.
# 
cdp.psow.add_process("cutatgrain", "sndfile", "sndfile", 2, "Cut soundfile at specified time.")
params = []
cdp.psow.cutatgrain.add_mode(1, params, "CUT BEFORE SPECIFIED TIME")
params = []
cdp.psow.cutatgrain.add_mode(2, params, "CUT AT & AFTER SPECIFIED TIME")
#
# PSOW DELETE
#
# USAGE:
# psow del infile outfile pitch-brkpnt-data propkeep segcnt
# 
# Time shrink sound by deleting proportion of pitch-syncd grains.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# PROPKEEP           Proportion of chunks to keep.
#                    '2' keeps 1 in 2:    '7' Keeps 1 in 7:   etc.
# SEGCNT             no of grains in a chunk.
# 
#
# PSOW DUPL
#
# USAGE:
# psow dupl infile outfile pitch-brkpnt-data repeat-cnt segcnt
# 
# Timestretch/transpose a sound by duplicating the pitch-syncd grains.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# REPEAT-CNT         Number of repetitions of each chunk.
# SEGCNT             no of grains in a chunk .
# 
#cdp.psow.add_process("dupl", "sndfile", "sndfile", None, u"Timestretch/transpose by duplicating the pitch-syncd grains.")
#params = []
#cdp.psow.dupl.add_parameters(params)
#
# PSOW FEATURES
#
# USAGE: psow features 1-2 infile1 outfile pitch-brkpnt-data segcnt
#               trans  vibfrq  vibdepth  spectrans  hoarseness  attenuation
#               subharmno  subharmamp fof-stretching [-a]
# Impose new features on vocal-type sound, preserving or modifying FOF-grains.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# SEGCNT         No of grains in a chunk retained as-is.
# TRANS          Pitch transposition (semitones). Works differently in 2 modes.
#                1) Transpose accompanied by timewarp (pitch up, snd shorter).
#                2) Transposed pitch accompanied by additional lower pitch.
# VIBFRQ         Frequency of any added vibrato.
# VIBDEPTH       Depth (semitones) of any added vibrato.
# SPECTRANS      Transposition of spectrum (not fundamental) in semitones.
# HOARSENESS     Degree of hoarseness of voice (Range 0 to 1).
# ATTENUATION    Attenuation (maybe necessary when 'fof-stretching') (Range 0-1)
# SUBHARMNO      Amount by which fundamental divided, 0 or 1 gives NO subharm.
# SUBHARMAMP     Level of any subharmonic introduced.
# FOF-STRETCHING Time-extension of FOFs: does NOT stretch sound (Range 1 to 512)
# -a             Alternative algorithm for fof_stretch.
cdp.psow.add_process("features", "sndfile", "sndfile", 2, "Impose new features on vocal-type sound.")
params = []
cdp.psow.features.add_mode(1, params, "TRANSPOSE WITH PITCHWARP")
params = []
cdp.psow.features.add_mode(2, params, "TRANSPOSE WITH ADDED PITCH")
#
# PSOW GRAB
#
# USAGE:
# psow grab infil outfil pitch-brkpnt-data time dur segcnt spectrans density rand gain
# 
# Grab a pitch-syncd grain from a file, and use it to create a new sound
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# TIME               Time at which to grab grain(s).
# DUR                Output file duration. Dur ZERO grabs SINGLE grain(chunk).
# SEGCNT             no of grains in a chunk.
# DENSITY            Rate at which the chunks in the outfile succeed one another.
#                    1: grains follow on, 2: grains overlap by 2, 3: by 3 etc
#                    0.5: grains separated by equivalent silence etc.
#                    overlap by 2 can transpose up by 8va, without changing spectrum.
# SPECTRANS          Transposition of spectrum (not fundamental) in semitones.
# RAND               Randomisation of position of grainchunks in output.
#                    Randomisation introduces noisiness into output sound.
# GAIN               Overall gain: may need to reduce this if density > 1 in output.
# 
cdp.psow.add_process("grab", "sndfile", "sndfile", None, "Grab a pitch-sync’d grain and use to create a new sound.")
params = []
cdp.psow.grab.add_parameters(params)
#
# PSOW INTERLEAVE
#
# USAGE: psow interleave
#        infile1 infile2 outfile pbrk1 pbrk2 grplen bias bal weight
# 
# Interleave FOFs from two different files.
# 
# PBRK1  a breakpoint file with time & frq info about infile1.
#        File may contain zeros (indicating moments of no-signal)
#        but NOT pitch-zeros (indicating moments of no-pitch).
#        It must contain SOME significant frequency information.
# PBRK2  Similar file for infile 2.
# GRPLEN number of FOFS in each manipulated segment.
# BIAS   Is outpitch biased to one or other of infiles ?.
#        0:  no bias.  1:  biased to 1st.   -1: biased to 2nd.
#        intermediate vals give intermediate degrees of bias.
# BAL    level balance of components of 2 input files in output.
#        1.0:  equally loud.  >1:   1st louder.  <1:   2nd louder.
# WEIGTH relative number of components of 2 input files in output.
#        1.0:  equal. >1: more of 1st. <1: more of 2nd.
# 
cdp.psow.add_process("interleave", "brkfile", "brkfile", None, "Interleave FOFs from two different breakpoint files.")
params = []
cdp.psow.interleave.add_parameters(params)
#
# PSOW INTERP
#
# USAGE: psow interp infile1 infile2 outfile startdur interpdur enddur
#                   vibfrq  vibdepth  tremfrq  tremdepth
# 
# Interpolate between 2 pitch-synchronised grains, to produce new sound.
# 
# STARTDUR   Duration to sustain initial grain.
# INTERPDUR  Duration of interpolation.
# ENDDUR     Duration to sustain final grain.
# VIBFRQ     Frequency of any added vibrato.
# VIBDEPTH   Depth (semitones) of any added vibrato.
# TREMFRQ    Frequency of any added tremolo.
# TREMDEPTH  Depth of any added tremolo.
# 
# Process assumes your files each contain a single pitchsync grain.
# obtained using 'psow grab' with output duration 0.0
# 
cdp.psow.add_process("interp", "sndfile", "sndfile", None, "Interpolate between two GRAB’d pitch-sync’d grains.")
params = []
cdp.psow.interp.add_parameters(params)
#
# PSOW LOCATE
#
# USAGE: psow locate infil pitch-brkpnt-data time
# 
# Gives exact time of grain-start nearest to specified time.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# TIME           Time at which find grain.
# 
cdp.psow.add_process("locate", "sndfile", "sndfile", None, "Show exact grain-start nearest to specified time.")
params = []
cdp.psow.locate.add_parameters(params)
#
# PSOW IMPOSE
#
# USAGE: psow synth infile1 infile2 outfile pitch-brkpnt-data depth wsize gate
# 
# Impose vocal FOFs in 1st sound onto the 2nd sound.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# DEPTH  Depth of application of FOFS to the 2nd sound.
# WSIZE  Windowsize (mS) to envelope track 2nd sound (for normalisation).
# GATE   Level (decibels) in 2nd sound at which it's assumed to be zero.
# 
cdp.psow.add_process("impose", "sndfile", "sndfile", None, "Impose vocal FOFs in 1st sound onto the 2nd sound.")
params = []
cdp.psow.impose.add_parameters(params)
#
# PSOW REINFORCE
#
# USAGE:
# psow reinforce 1 infil outfil reinforcement-data pitch-brkpnt-data [-ddelay] [-s]
# psow reinforce 2 infil outfil reinforcement-data pitch-brkpnt-data [-wweight]
# 
# MODE 1: Reinforce the harmonic content of the sound.
# MODE 2: Reinforce sound with inharmonic partials.
# 
# REINFORCEMENT-DATA File of pairs of values, which represent
#      a harmonic number (2-256) + level relative to src (>0.0 - 16.0).
#      In MODE 2, the 'harmonics' may be fractional (range >1 - 256).
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# 
# -s      FOFs generated for higher harmonics which coincide with
#         FOFs of lower harmonics, are omitted.
# delay   mS delay of onset of the added harmonics.
# weight  Sustain inharmonic components. Higher weight, longer sustain.
#         A very high weight may cause buffers to overflow. Default 4.0
# 
cdp.psow.add_process("reinforce", "sndfile", "sndfile", 2, "Reinforce harmonics.")
params = []
cdp.psow.reinforce.add_mode(1, params, "REINFORCE HARMONIC CONTENT")
params = []
cdp.psow.reinforce.add_mode(2, params, "REINFORCE WITH INHARMONICS")
#
# PSOW REPLACE
#
# USAGE: psow replace infile1 infile2 outfile pbrk1 pbrk2 grpcnt
# 
# Combine fofs of first sound with pitch of 2nd.
# 
# PBRK1  a breakpoint file with time & frq info about infile1.
#        File may contain zeros (indicating moments of no-signal)
#        but NOT pitch-zeros (indicating moments of no-pitch).
#        It must contain SOME significant frequency information.
# PBRK2  Similar file for infile 2.
# GRPCNT Number of FOFS in a chunk.
# 
# This process assumes that BOTH the input files have pitched-grains
# 
cdp.psow.add_process("replace", "sndfile", "sndfile", None, "Combine FOFs of 1st sound with the pitch of 2nd.")
params = []
cdp.psow.replace.add_parameters(params)
#
# PSOW SPACE
#
# USAGE: psow space infile1 outfile
#           pitch-brkpnt-data subno separation balance hisuppress
# 
# Split alternating FOFs between different spatial locations.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# SUBNO       Subharmonic number (divides frequency of source) (Range 2-5).
# SEPARATION  spatial separation of alternate FOFs (range -1 to 1).
#      0:  no separation, all output is stereo-centred.
#      1:  alternate FOFS to widest spread, starting with far right position.
#      -1: alternate FOFS to widest spread, starting with far left position.
#      intermediate vals give intermediate degrees of spatial separation.
# BALANCE    of left:right components (0-8).
#      1.0:  leftward & rightward levels equal.
#      >1:   leftward signal divided by balance. (Bias to right)
#      <1:   rightward signal multiplied by balance. (Bias to left)
# HISUPPRESS Suppression of high-frequency components (0-1).
# 
cdp.psow.add_process("space", "sndfile", "sndfile", None, "Distribute the alternate FOFs over a stereo space.")
params = []
cdp.psow.space.add_parameters(params)
#
# PSOW SPLIT
#
# USAGE: psow split infile1 outfile pitch-brkpnt-data subharmno uptrans balance
# 
# Split vocal FOFs into subharmonic and upwardly transposed pitch.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# SUBHARMNO  Subharmonic number (divides frequency of source) (Range 2-8).
# UPTRANS    Upward transposition in semitones (Range 0 - 48).
# BALANCE    Level of up-transposed components relative to subharms (0-8).
# 
cdp.psow.add_process("split", "sndfile", "sndfile", None, "Split vocal FOFs into subharmonic & upward pitch.")
params = []
cdp.psow.split.add_parameters(params)
#
# PSOW STRETCH
#
cdp.psow.add_process("stretch", "sndfile", "sndfile", None, "Time-stretch/transpose by repositioning pitch-sync’d grains.")
params = []
cdp.psow.stretch.add_parameters(params)
#
# PSOW STRTRANS
#
# USAGE:
# psow strtrans infile outfile pitch-brkpnt-data timestretch segcnt trans
# 
# Timestretch/transpose a sound by repositioning the pitch-syncd grains,
# and overlapping them.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# TIMESTRETCH        Proportion by which sound is stretched (or shrunk).
# SEGCNT             no of grains in a chunk retained as-is,
#                    while gaps between segments are stretched.
# TRANS              Transposition in semitones, corresponds to overlap between
#                    succesive segments.
#                    NB This parameter interacts with 'Timestretch' parameter
#                    in unpredicable ways.
# 
cdp.psow.add_process("strtrans", "sndfile", "sndfile", None, "Time-stretch/transpose by repositioning, with overlap.")
params = []
cdp.psow.strtrans.add_parameters(params)
#
# PSOW SUSTAIN
#
# USAGE:
# psow sustain infil outfil pitch-brkpnt-data time dur segcnt vibfrq vibdepth
# 
# Freeze and Sustain a sound on a specified pitch-syncd grain.
# 
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# TIME           Time at which to freeze grain(s).
# DUR            Output file duration. (Greater than input file's duration).
# SEGCNT         no of grains in a chunk.
# VIBFRQ         Frequency of any added vibrato.
# VIBDEPTH       Depth (semitones) of any added vibrato.
# 
cdp.psow.add_process("sustain", "sndfile", "sndfile", None, "Sustain a pitch-sync’d FOF within a sound.")
params = []
cdp.psow.sustain.add_parameters(params)
#
# PSOW SUSTAIN2
#
# USAGE:
# psow sustain2 infil outfil start end  dur vibfrq vibdepth nudge
# 
# Freeze and Sustain a sound on a specified grain.
# 
# START          Time at which to cut grain.
# END            Time OF end of grain.
# DUR            Output file duration. (Greater than input file's duration).
# VIBFRQ         Frequency of any added vibrato.
# VIBDEPTH       Depth (semitones) of any added vibrato.
# NUDGE			Move selected grain position by 'nudge' zerocrossings
# 
cdp.psow.add_process("sustain2", "sndfile", "sndfile", None, "Sustain an explicitly specific pitch-sync’d FOF within a sound.")
params = []
cdp.psow.sustain2.add_parameters(params)
#
# PSOW SYNTH
#
# USAGE: psow synth 1-5 infile1 outfile [oscdatafile] pitch-brkpnt-data depth
# 
# Impose vocal FOFs on a stream of synthesized sound.
# 
# OSCDATAFILE        (Amplitude values range is 0.0 to 1.0)
#   Mode 1: Each line has pair of values for frequency and amplitude.
#   Mode 2: Each line has pair of values for midipitch and amplitude.
#   Mode 3: Each line has frq and amp data in the 'filter varibank' format.
#   Mode 4: Each line has midipitch & amp data in 'filter varibank' format.
#   Mode 5: No 'oscdatafile' ... synthetic source is noise.
# PITCH-BRKPNT-DATA  a breakpoint file with time and frq information.
#                    File may contain zeros (indicating moments of no-signal)
#                    but NOT pitch-zeros (indicating moments of no-pitch).
#                    It must contain SOME significant frequency information.
# DEPTH              Depth of application of FOFS to the synthesized sound.
# 
cdp.psow.add_process("synth", "sndfile", "sndfile", 5, "Impose vocal FOFs on a stream of synthesised sound.")
params = []
cdp.psow.synth.add_mode(1, params, "FIXED FREQUENCY BANDS")
params = []
cdp.psow.synth.add_mode(2, params, "FIXED MIDI BANDS")
params = []
cdp.psow.synth.add_mode(3, params, "VARIABLE FREQUENCY BANDS")
params = []
cdp.psow.synth.add_mode(4, params, "VARIABLE MIDI BANDS")
params = []
cdp.psow.synth.add_mode(5, params, "NOISE")
#
# REPITCH
#
#
# REPITCH ANALENV
#
# CDP Release 5 2005
# repitch analenv inanalfile outenvfile
# 
# EXTRACT THE WINDOW-LOUDNESS ENVELOPE OF AN ANALYSIS FILE
# 
# Extracts loudness of each window of analysis file.
# Output data synchronous with pitch or formant data from same analfile
# 
# 
cdp.repitch.add_process("analenv", "analfile", "analfile", None, "Extract the window-loudness envelope of an analysis file.")
params = []
cdp.repitch.analenv.add_parameters(params)
#
# REPITCH APPROX
#
# CDP Release 5 2005
# repitch approx mode pitchfile outfile [-pprange] [-ttrange] [-ssrange]
# 
# MAKE AN APPROXIMATE COPY OF A PITCHFILE.
# 
# PRANGE  Interval (semitones) over which pitch +- randomly varies from orig.
#         Range > 0.0
# TRANGE  Time-interval (msecs) by which pitchval can stray from orig time.
#         Applied to turning-points in pitch-contour.
#         Range: from duration of 1 analysis window to duration of entire file.
# SRANGE  Time-interval (msecs) over which pitch contour scanned.
#         Pitchshift by a semitone within srange, indicates pitch rise or fall.
#         Range: from duration of 8 analwindows to (approx) dur of infile.
# 
# MODES....
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# Prange, trange and srange may vary over time.
# 
# 
cdp.repitch.add_process("approx", "pitchfile", "pitchfile", 2, "Make an approximate copy of pitch in a pitch datafile.")
params = []
cdp.repitch.approx.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.approx.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH COMBINE
#
# CDP Release 5 2005
# repitch combine 1 pitchfile    pitchfile2    outtransposfile
# repitch combine 2 pitchfile    transposfile  outpitchfile
# repitch combine 3 transposfile transposfile2 outtransposfile
# 
#        GENERATE TRANSPOSITION DATA FROM 2 SETS OF PITCH DATA,
#           OR TRANSPOSE PITCH DATA WITH TRANSPOSITION DATA,
# OR COMBINE 2 SETS OF TRANSPOSITION DATA TO FORM NEW TRANSPOSITION DATA,
#                  PRODUCING BINARY DATAFILE OUTPUT.
# 
# PITCHFILE       binary pitchdatafile OR time/pitch(frq) brkpnt file
# TRANSPOSFILE    binary transposition file OR time/transpos(ratio) brkpnt file
# OUTPITCHFILE    binary pitchdatafile
# OUTTRANSPOSFILE binary transpositionfile
# 
# NB: It's IMPOSSIBLE to generate binary outfile from exclusively brkpnt infiles.
# 
# 
cdp.repitch.add_process("combine", "pitchfile", "pitchfile", 3, "Pitch+Pitch->Transposition, P+T->P, T+T->T")
params = []
cdp.repitch.combine.add_mode(1, params, "PITCH+PITCH TO TRANSPOS")
params = []
cdp.repitch.combine.add_mode(2, params, "PITCH+TRANSPOS TO PITCH | TRANSPOSEFI")
params = []
cdp.repitch.combine.add_mode(3, params, "TRANSPOS+TRANS TO TRANS")
#
# REPITCH COMBINEB
#
# CDP Release 5 2005
# repitch combineb 1 pitchfile    pitchfile2    outtbrkfile [-dI]
# repitch combineb 2 pitchfile    transposfile  outpbrkfile [-dI]
# repitch combineb 3 transposfile transposfile2 outtbrkfile [-dI]
# 
#        GENERATE TRANSPOSITION DATA FROM 2 SETS OF PITCH DATA,
#           OR TRANSPOSE PITCH DATA WITH TRANSPOSITION DATA,
# OR COMBINE 2 SETS OF TRANSPOSITION DATA TO FORM NEW TRANSPOSITION DATA,
#               PRODUCING A TIME/VAL BRKPNT FILE OUTPUT.
# 
# PITCHFILE    binary pitchdatafile OR time/pitch(frq) brkpnt file
# TRANSPOSFILE binary transposition file OR time/transpos(ratio) brkpnt file
# OUTPBRKFILE  time/pitch(frq) brkpnt file
# OUTTBRKFILE  time/transposition(ratio) brkpnt file
# 
# -d  I = acceptable pitch error in brkpntfile data-reduction.
#     Range > 1.0 : Default: eighth_tone = 0.250000
# 
# 
cdp.repitch.add_process("combineb", "pitchfile", "pitchfile", 3, "Pitch+Pitch->Transposition, P+T->P, T+T->T")
params = []
cdp.repitch.combineb.add_mode(1, params, "PITCH+PITCH TO TRANSPOS")
params = []
cdp.repitch.combineb.add_mode(2, params, "PITCH+TRANSPOS TO PITCH | TRANSPOSEFI")
params = []
cdp.repitch.combineb.add_mode(3, params, "TRANSPOS+TRANS TO TRANS")
#
# REPITCH CUT
#
# CDP Release 5 2005
# repitch cut 1 pitchfile outpitchfile starttime
# repitch cut 2 pitchfile outpitchfile endtime
# repitch cut 3 pitchfile outpitchfile starttime endtime
# 
# CUT OUT AND KEEP A SEGMENT OF A BINARY PITCH-DATAFILE.
# 
# 
cdp.repitch.add_process("cut", "pitchfile", "pitchfile", 3, "Cut out and keep a segment of a pitch datafile.")
params = []
cdp.repitch.cut.add_mode(1, params, "FROM STARTTIME")
params = []
cdp.repitch.cut.add_mode(2, params, "TO ENDTIME")
params = []
cdp.repitch.cut.add_mode(3, params, "BETWEEN TIMES")
#
# REPITCH EXAG
#
# CDP Release 5 2005
# repitch exag 1-2 pitchfile outfile meanpch range
# repitch exag 3-4 pitchfile outfile meanpch       contour
# repitch exag 5-6 pitchfile outfile meanpch range contour
# 
# EXAGGERATE PITCH CONTOUR.
# 
# MEANPITCH pitch (MIDI) around which intervals stretched.
# RANGE     exagg pitch-range (multiply semitone-intvl). >0.
# CONTOUR   exagg pitch-contour. Values (0-1).
# 
# MODES....
# (1,3,5) Give a pitchfile as ouput.
# (2,4,6) Give a transposition file as output.
# 
# Meanpitch, range and contour may all vary over time.
# 
# 
cdp.repitch.add_process("exag", "pitchfile", "pitchfile", 6, "Exaggerate pitch contour of a pitch data file.")
params = []
cdp.repitch.exag.add_mode(1, params, "RANGE: PITCH OUT")
params = []
cdp.repitch.exag.add_mode(2, params, "RANGE: TRANSPOSITION OUT")
params = []
cdp.repitch.exag.add_mode(3, params, "CONTOUR: PITCH OUT")
params = []
cdp.repitch.exag.add_mode(4, params, "CONTOUR: TRANSPOS OUT")
params = []
cdp.repitch.exag.add_mode(5, params, "RANGE & CONTOUR:PITCH OUT")
params = []
cdp.repitch.exag.add_mode(6, params, "RANGE & CONTOUR:TRANSPOS OUT")
#
# REPITCH FIX
#
# CDP Release 5 2005
# repitch fix pitchfile outpitchfile
#        [-rt1] [-xt2] [-lbf] [-htf] [-sN] [-bf1] [-ef2] [-w] [-i]
# 
# MASSAGE PITCH DATA IN A BINARY PITCHFILE.
# Pitchdata may be viewed by running pitchinfo see, and viewing output in viewsf.
# 
# PITCHFILE & OUTPITCHFILE:binary pitchdata files generated by 'spec pitch' etc.
# 
# -r t1  Starttime:  remove pitch from time 't1' (default 0.0).
# -x t2  Endtime:    end pitch removal at time 't2' (default, end of file).
# -l bf  Bottom_frq: remove pitch below frequency 'bf'.
# -h tf  Top_frq:    remove pitch above frequency 'tf'.
# -s N   Smoothcnt:  smooth onset errors & glitches in pitchdata, N times.
# -b f1  Startfrq:   force start frequency to be 'f1'.
# -e f2  Endfrq:     force end frequency to be 'f2'.
# -w     removes 2-window glitches (Default: 1-window) (Use ONLY with -s)
# -i     interpolate through ALL non-pitch windows in pitch_data,
#        producing pitch everywhere.
# RULES.........
# (1) AT LEAST ONE flag must be used.
# (2) When pitches are removed they are replaced by a 'no-pitch' indicator.
#     These (and any already existing unpitched windows in the file) can be
#     converted to pitch-data (by interpolation between adjacent pitches)
#     using the -i flag.
# (3) With multiple flags, ORDER of operations inside program is....
#     REMOVE-TIMEWISE(rx),REMOVE-FRQWISE(lh),SMOOTH(sw),SET-ENDVALS(be),INTERP(i)
# 
# 
cdp.repitch.add_process("fix", "pitchfile", "pitchfile", None, "Massage pitch data in a pitch datafile.")
params = []
cdp.repitch.fix.add_parameters(params)
#
# REPITCH GENERATE
#
# CDP Release 5 2005
# repitch generate outpitchdatafile midipitch-data srate
# 
# CREATE BINARY PITCHDATA FILE FROM A TEXTFILE OF TIME-MIDI VALUE PAIRS
# 
# MIDIPITCH-DATA is a list of paired time and midi-note-values
#      where times must start at zero and increase,
#      and note values may be numeric MIDI values (possibly fractional)
#      OR note names (A,B,C,D,E,F or G)
#      possibly followed by '#'(sharp) or 'b'(flat)
#      followed by an octave number between -5 and 5
#      where 0 corresponds to the octave starting at middle C.
# 
# SRATE is the sample rate of the soundfile that might later be generated
#      from the binary pitch data.
# 
# 
cdp.repitch.add_process("generate", "brkfile", "brkfile", None, "Create binary pitchdata from a textfile of time midi value pairs.")
params = []
cdp.repitch.generate.add_parameters(params)
#
# REPITCH GETPITCH
#
# CDP Release 5 2005
# repitch getpitch 1 infile outfile pfil 
# 	 [-tR] [-gM] [-sS] [-nH] [-lL] [-hT] [-a] [-z]
# repitch getpitch 2 infile outfile bfil 
# 	 [-tR] [-gM] [-sS] [-nH] [-lL] [-hT] [-di] [-a]
# 
# ATTEMPT TO EXTRACT PITCH FROM SPECTRAL DATA.
# 
# outfile  If resynthesized, produces tone at detected (possibly varying) pitch.
# 
# pfil     (MODE 1) Binary output file containing pitch information.
# bfil     (MODE 2) breakpoint (text) outfile of pitch info (as time/Hz pairs).
#          Either of these may be reused in other pitch-manipulating options.
# 
# -t R     R = Tuning range(semitones) within which harmonics accepted as in tune
#          (Default 1)
# -g M     M = minimum number of adjacent windows that must be pitched,
#          for a pitch-value to be registered (Default 2).
# -s S     S = signal to noise ratio, in decibels. (Default 80dB)
#          Windows which are more than SdB below maximum level in sound, are
#          assumed to be noise, & any detected pitchvalue is assumed spurious.
# -n H     H = how many of the 8 loudest peaks in spectrum must be harmonics
#          to confirm sound is pitched: Default 5.
# -l L     L = frequency of LOWEST acceptable pitch (Default min: 9Hz).
# -h T     T = frequency of TOPMOST acceptable pitch (Default max: nyquist/8).
# -d i     i = acceptable pitch-ratio error in data reduction. (semitones)
#          Default 1/8 tone = 0.250000
# -a       Alternative pitch-finding algorithm (avoid N<2).
# -z       Retain unpitched windows (set them to -1)
#          Default: Set pitch by interpolation between adjacent pitched windows.
# 
# 
cdp.repitch.add_process("getpitch", "analfile", "analfile", 2, "Attempt to extract pitch from spectral data.")
params = []
cdp.repitch.getpitch.add_mode(1, params, "TO BINARY FILE")
params = []
cdp.repitch.getpitch.add_mode(2, params, "TO TEXTFILE")
#
# REPITCH INSERTSIL
#
# CDP Release 5 2005
# repitch insertsil mode infile outfile silence-data
# 
# MARK AREAS AS SILENT IN A PITCHDATA FILE
# 
# MODES
# 1  data as times.
# 2  data as (grouped) sample count: Count samples in mono, pairs in stereo etc
# 
# SILENCE-DATA
# is a a list of pairs of times between which silence is to be indicated.
# 
# 
cdp.repitch.add_process("insertsil", "pitchfile", "pitchfile", None, "Mark areas as silent in a pitchdata file.")
params = []
cdp.repitch.insertsil.add_parameters(params)
#
# REPITCH INSERTZEROS
#
# CDP Release 5 2005
# repitch insertzeros mode infile outfile zeros-data
# 
# MARK AREAS AS UNPITCHED IN A PITCHDATA FILE
# 
# MODES
# 1  data as times.
# 2  data as (grouped) sample count: Count samples in mono, pairs in stereo etc
# 
# ZEROS-DATA
# is a list of pairs of times between which unpitched data to be indicated.
# 
# 
cdp.repitch.add_process("insertzeros", "pitchfile", "pitchfile", 2, "Mark areas as unpitched in a pitchdata file.")
params = []
cdp.repitch.insertzeros.add_mode(1, params, "DATA AS TIMES")
params = []
cdp.repitch.insertzeros.add_mode(2, params, "DATA AS (GROUPED) SAMPLECNT")
#
# REPITCH INTERP
#
# CDP Release 5 2005
# repitch interp 1-2 infile outfile
# 
# REPLACE NOISE OR SILENCE BY PITCH INTERPOLATED FROM EXISTING PITCHES
# 
# Mode 1 glides from previous valid pitch to next vaild pitch.
# Mode 2 sustains previous valid pitch until next vaild pitch appears.
# 
# 
cdp.repitch.add_process("interp", "pitchfile", "pitchfile", 2, "Replace noise or silence by pitch interpolated from existing pitches.")
params = []
cdp.repitch.interp.add_mode(1, params, "GLIDES BETWEEN VALID PITCHES")
params = []
cdp.repitch.interp.add_mode(2, params, "SUSTAINS BETWEEN VALID PITCHES")
#
# REPITCH INVERT
#
# CDP Release 5 2005
# repitch invert mode pitchfile outfile map [-mmeanpch] [-bbot] [-ttop]
# 
# INVERT PITCH CONTOUR OF A PITCH DATA FILE.
# 
# MAP	   Set map to ZERO if no mapping is required..OTHERWISE
#           map is a file of paired values showing how intervals
#           (in, possibly fractional, SEMITONES)
#           are to be mapped onto their inversions.
#           Range -96 to 96.
# MEANPCH   pitch (MIDI) around which pitchline inverted.
#           Range: MIDI equivalents of 9Hz to nyquist.
# BOT       bottom pitch (MIDI) permissible (default 0).
#           Range: MIDI equivalents of 9Hz to nyquist.
# TOP       top pitch (MIDI) permissible (default 127).
#           Range: MIDI equivalents of 9Hz to nyquist.
# MODES.
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# Meanpitch may vary over time.
# 
# 
cdp.repitch.add_process("invert", "pitchfile", "pitchfile", 2, "Invert pitch contour of a pitch data file.")
params = []
cdp.repitch.invert.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.invert.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH NOISETOSIL
#
# CDP Release 5 2005
# repitch noisetosil infile outfile
# 
# REPLACE UNPITCHED WINDOWS BY SILENCE
# 
# 
cdp.repitch.add_process("noisetosil", "pitchfile", "pitchfile", None, "Replace unpitched windows by silence.")
params = []
cdp.repitch.noisetosil.add_parameters(params)
#
# REPITCH PCHSHIFT
#
# CDP Release 5 2005
# repitch pchshift pitchfile outpitchfile transposition
# 
# SHIFTS PITCHES IN PITCHDATA FILE BY CONSTANT NO OF SEMITONES.
# 
# (To transpose pitch of spectrum in time-varying way,'repitch transpose[f]')
# 
# 
cdp.repitch.add_process("pchshift", "pitchfile", "pitchfile", 4, "Shift pitch data by fixed (fractional) semitones.")
params = []
cdp.repitch.pchshift.add_mode(1, params, "TRANSPOS AS RATIO")
params = []
cdp.repitch.pchshift.add_mode(2, params, "TRANSPOS AS SEMITONES")
params = []
cdp.repitch.pchshift.add_mode(3, params, "TRANSPOS IN SEMITONES")
params = []
cdp.repitch.pchshift.add_mode(4, params, "TRANSPOS AS BINARY DATA")
#
# REPITCH PCHTOTEXT
#
# CDP Release 5 2005
# repitch pchtotext infile outfile
# 
# CONVERT BINARY PITCH DATA TO TEXTFILE
# 
# 
cdp.repitch.add_process("pchtotext", "pitchfile", "pitchfile", None, "Convert binary pitch data to textfile.")
params = []
cdp.repitch.pchtotext.add_parameters(params)
#
# REPITCH PITCHTOSIL
#
# CDP Release 5 2005
# repitch pitchtosil infile outfile
# 
# REPLACE PITCHED WINDOWS BY SILENCE
# 
# 
cdp.repitch.add_process("pitchtosil", "pitchfile", "pitchfile", None, "Replace pitched windows by silence.")
params = []
cdp.repitch.pitchtosil.add_parameters(params)
#
# REPITCH QUANTISE
#
# CDP Release 5 2005
# repitch quantise mode pitchfile outfile q-set [-o]
# 
# QUANTISE PITCHES IN A PITCH DATA FILE.
# 
# q_set   a file of (possibly fractional) MIDI pitchvals
#         over which pitch to be quantised.
# -o		 duplicates q_set in all octave transpositions
# 
# MODES....
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# 
# 
cdp.repitch.add_process("quantise", "pitchfile", "pitchfile", 2, "Quantise pitches in a pitch data file.")
params = []
cdp.repitch.quantise.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.quantise.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH RANDOMISE
#
# CDP Release 5 2005
# repitch randomise mode pitchfile outfile maxinterval timestep [-sslew]
# 
# RANDOMISE PITCH LINE.
# 
# MAXINTERVAL (semitones) over which pitches can +- randomvary.
#             Range 0 to 96: Value or brkpnt file.
# TIMESTEP    maximum timestep between random pitch fluctuations (milliseconds).
#             Timesteps are random values less than this.
#             Range: duration of 1 anal window to dur of entire file.
# SLEW	    e.g. 2:  upward variation range twice that of downward.
#     	    e.g -3: downward variation range 3 times that of upward.
#     	    Range >1 || <-1.
# 
# MODES....
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# Maxinterval and timestep may vary over time.
# 
# 
cdp.repitch.add_process("randomise", "pitchfile", "pitchfile", 2, "Randomise pitch line in a pitch data file.")
params = []
cdp.repitch.randomise.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.randomise.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH SMOOTH
#
# CDP Release 5 2005
# repitch smooth mode pitchfile outfile timeframe [-pmeanpch] [-h]
# 
# SMOOTH PITCH CONTOUR IN A PITCH DATA FILE.
# 
# TIMEFRAME (millisecs) over which to interpolate pitch values.
#           Range: duration of 1 anal window to dur of entire file.
# -p        interp between PEAK value in each timeframe block of pitch values.
#           MEANPITCH is pitch from which peaks measured
#           (and must be within pitch range, in every timeframe block).
#           Peak is maximum displacement from mean (up or down).
# -h        At end of file, hold last interpolated pitchvalue calculated.
#           Default: interpolate thence to last actual value in input.
# MODES....
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# Timeframe and meanpitch may vary over time.
# 
# 
cdp.repitch.add_process("smooth", "pitchfile", "pitchfile", 2, "Smooth pitch contour in a pitch data file.")
params = []
cdp.repitch.smooth.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.smooth.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH SYNTH
#
# CDP Release 5 2005
# repitch synth binarypitchfile outanalfile harmonics-data
# 
# CREATE SPECTRUM OF A SOUND FOLLOWING THE PITCH CONTOUR IN THE PITCH FILE
# 
# HARMONICS-DATA is a list of the amplitude of each harmonic in sequence, from 1 upwards
# Amplitudes must lie in the range 0-1
# 
# 
cdp.repitch.add_process("synth", "pitchfile", "pitchfile", None, "Create spectrum by following the pitch contour in a pitch datafile.")
params = []
cdp.repitch.synth.add_parameters(params)
#
# REPITCH TRANSPOSE
#
# CDP Release 5 2005
# repitch transpose 1-3 infile          outfile transpos [-lminfrq][-hmaxfrq][-x]
# repitch transpose 4   infile transpos outfile          [-lminfrq][-hmaxfrq][-x]
# 
# TRANSPOSE SPECTRUM (SPECTRAL ENVELOPE ALSO MOVES)
# 
# MODES
# 1    transposition as a frq ratio.
# 2    transposition in (fractions of) octaves.
# 3    transposition in (fractions of) semitones.
# 4    transposition as a binary data file.
# 
# -l     MINFRQ = minimum frq, below which data is filtered out.
# -h     MAXFRQ = maximum frq, above which data is filtered out.
# -x     Fuller spectrum.
# 
# frq-ratio, octave or semitone transpositions may vary over time.
# 
# 
cdp.repitch.add_process("transpose", "analfile", "analfile", 4, "Transpose spectrum (spectral envelope moves).")
params = []
cdp.repitch.transpose.add_mode(1, params, "TRANSPOS AS RAT")
params = []
cdp.repitch.transpose.add_mode(2, params, "TRANSPOS IN OCTAVES")
params = []
cdp.repitch.transpose.add_mode(3, params, "TRANSPOS IN SEMITONES")
params = []
cdp.repitch.transpose.add_mode(4, params, "TRANSPOS AS BINARY DATA")
#
# REPITCH TRANSPOSEF
#
# CDP Release 5 2005
# repitch transposef 1-3 infile outfile -fN|-pN [-i] transpos [-lminf][-hmaxf][-x]
# repitch transposef 4   infile transpos outfile -fN|-pN [-i] [-lminf][-hmaxf][-x]
# 
# TRANSPOSE SPECTRUM : BUT RETAIN ORIGINAL SPECTRAL ENVELOPE
# 
# MODES
# 1    transposition as a frq ratio.
# 2    transposition in (fractions of) octaves.
# 3    transposition in (fractions of) semitones.
# 4    transposition as a binary data file.
# 
# -f   extract formant envelope linear frqwise,
#      using 1 point for every N equally-spaced frequency-channels.
# -p   extract formant envelope linear pitchwise,
#      using N equally-spaced pitch-bands per octave.
# -i   quicksearch for formants (less accurate).
# 
# -l     MINF = minimum frq, below which data is filtered out.
# -h     MAXF = maximum frq, above which data is filtered out.
# -x     Fuller spectrum.
# 
# frq-ratio, octave or semitone transpositions may vary over time.
# maxfrq and minfrq may vary over time.
# 
# 
cdp.repitch.add_process("transposef", "analfile", "analfile", 4, "Transpose spectrum keeping original spectral envelope.")
params = []
cdp.repitch.transposef.add_mode(1, params, "TRANSPOS AS RAT")
params = []
cdp.repitch.transposef.add_mode(2, params, "TRANSPOS IN OCTAVES")
#
# REPITCH VIBRATO
#
# CDP Release 5 2005
# repitch vibrato mode pitchfile outfile vibfreq vibrange
# 
# ADD VIBRATO TO PITCH IN A PITCH DATA FILE.
# 
# VIBFREQ   frequency of vibrato itself (Hz). Values >0.
# VIBRANGE  max interval vibrato moves away from central pitch (semitones).
#           Values >0.
# 
# MODES....
# (1) Gives a pitchfile as ouput.
# (2) Gives a transposition file as output.
# 
# Vibfreq and vibrange may vary over time.
# 
# 
cdp.repitch.add_process("vibrato", "pitchfile", "pitchfile", 2, "d vibrato to pitch in a pitch data file.")
params = []
cdp.repitch.vibrato.add_mode(1, params, "PITCH DATA OUT")
params = []
cdp.repitch.vibrato.add_mode(2, params, "TRANSPOSITION DATA OUT")
#
# REPITCH VOWELS
#
# CDP Release 5 2005
# repitch vowels infile outfile vowel-data halfwidth curve pk_range fweight foffset
# 
# CREATE SPECTRUM OF VOWEL SOUND(S) FOLLOWING PITCH CONTOUR IN PITCH FILE
# 
# VOWEL-DATA is a vowel, OR a file of paired time/vowel values
# where vowel is one of the following strings
#      ee : as in 'heat'
#      i  : as in 'hit'
#      ai : as in 'hate'
#      aii: as in scottish 'e'
#      e  : as in 'pet'
#      a  : as in 'pat'
#      ar : as in 'heart'
#      o  : as in 'hot'
#      or : as in 'taught'
#      u  : as in 'hood'
#      uu : as in scottish 'you'
#      ui : as in scottish 'could'
#      x  : neutral vowel as in 'herb', or 'a'
#      xx : as in Southern English 'hub'
#      n  : as in mean, can, done
# 
# In brkpnt files, times must start at zero, and increase.
# 
# HALFWIDTH is half-width of formant, in Hz, as fraction of formant centre-frq (range .01 - 10)
# CURVE     is the steepness of the formant peak (range 0.1 to 10.0)
# PK_RANGE  ratio of (max) amplitude range of formant peaks to (max) total range (range 0 to 1)
# FWEIGHT   is amplitude weighting of fundamental (range 0 to 1)
# FOFFSET   is amount of scattering of frqs of harmonics from their true value (range 0 to 1)
# 
# 
# 
cdp.repitch.add_process("vowels", "pitchfile", "pitchfile", None, "Create spectrum of vowel sounds, following pitch contour in pitch datafile.")
params = []
cdp.repitch.vowels.add_parameters(params)
#
# STRETCH
#
#
# STRETCH SPECTRUM
#
# CDP Release 5 2005
# stretch spectrum mode infile outfile frq_divide maxstretch exponent [-ddepth]
# 
# STRETCH THE FREQUENCIES IN THE SPECTRUM
# 
# MODES:-
# 1     Stretch above the frq_divide.
# 2     Stretch below the frq_divide.
# 
# frq_divide is the frq above or below which spectral stretching takes place.
# maxstretch is the transposition ratio of the topmost spectral components.
# exponent   specifies the type of stretching required.	(> 0)
# depth      stretch effect on source (from 0 (no effect) to 1 (full effect))
# 
# depth can vary over time.
# 
# 
cdp.stretch.add_process("spectrum", "analfile", "analfile", 2, "Stretch the frequencies in the spectrum.")
params = []
cdp.stretch.spectrum.add_mode(1, params, "ABOVE GIVEN FRQ")
params = []
cdp.stretch.spectrum.add_mode(2, params, "BELOW GIVEN FRQ")
#
# STRETCH TIME
#
# CDP Release 5 2005
# stretch time 1 infile outfile timestretch
# stretch time 2 infile timestretch
# 
# TIME-STRETCHING OF INFILE.
# In mode 2, program calculates length of output, only.
# Timestretch may itself vary over time.
# 
# 
cdp.stretch.add_process("time", "analfile", "analfile", 2, "Time stretch the input file.")
params = [
        ["timestretch", 0, None, "timestretch"]
        ]
cdp.stretch.time.add_mode(1, params, "DO TIME_STRETCH")
"""
params = []
cdp.stretch.time.add_mode(2, params, "GET OUTPUT LENGTH")
"""
#
# TEXTURE
#
#
# TEXTURE SIMPLE
#
# CDP Release 5 2005
# USAGE:
# texture simple mode infile [infile2...] outfile notedata outdur packing scatter
#         tgrid sndfirst sndlast  mingain maxgain  mindur maxdur  minpich maxpich
#              [-aatten] [-pposition] [-sspread] [-rseed] [-w]
# MODES:-
# 1)  ON A GIVEN HARMONIC-FIELD        3)  ON A GIVEN HARMONIC-SET
# 2)  ON CHANGING HARMONIC-FIELDS      4)  ON CHANGING HARMONIC-SETS
# 5)  NONE
# notedata: infofile, insnd 'pitches',harmonic fields pitches etc.
# outdur:           (min) duration of outfile
# packing:          (average) time between event onsets.
# scatter:          randomisation of event-onsets (0 - 10)
# tgrid:            minstep(MS) quantised timegrid(for grp starttimes)(default 0)
# sndfirst,sndlast: 1st,last snd to use,from list of insnds(range:1 - no.of snds)
# mingain,maxgain:  minimum & maximum level of input events (1-127:default 64,64)
# mindur,maxdur:    minimum & maximum duration of events in texture
# minpich,maxpich:  minimum & maximum pitch (MIDI VALUE):
# atten:            overall attenuation of the output
# position:         centre of output sound-image (0(Left) 1(Right): default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# 
# 
cdp.texture.add_process("simple", "sndfile", "sndfile", 5, "Texture of events, generated from 1 or more sounds.")
params = []
cdp.texture.simple.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.simple.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.simple.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.simple.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.simple.add_mode(5, params, "NEUTRAL")
#
# TEXTURE GROUPED
#
# CDP Release 5 2005
# TEXTURE OF EVENT-GROUPS: USAGE: texture grouped mode infile [infile2..] outfile
# notedata outdur packing scatter tgrid
# sndfirst sndlast mingain maxgain mindur maxdur minpitch maxpitch phgrid gpspace
# gpsprange amprise contour gpsizelo gpsizehi gppaklo gppakhi gpranglo gpranghi
#                    [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:   infofile, 'pitch' of insnds, harmonic fields etc.
# outdur:     (min) duration of outfile
# packing:    (average) time between group onsets.
# scatter:    randomisation of event-onsets (0 - 10)
# tgrid:      minstep(MS) quantised timegrid(for grp starttimes)(default 0)
# sndfirst,sndlast: 1st,last snd to use, from list of insnds(range:1 - all)
# mingain,maxgain:  min & max level of input events (1-127:default 64,64)
# mindur,maxdur:    min & max duration of events in texture
# minpitch,maxpitch:min & max pitch (MIDI VALUE)
# phgrid:     a timegrid (MS) applying WITHIN the groups
# gpspace:    spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:  spatial range of event-groups (Range 0-1: default 1)
# amprise:    amplitude change within groups: (0-127: default 0)
# contour:    amplitude contour of groups (Range 0-6: default 0)
# gpsizelo,gpsizehi:smallest,largest no. of events in groups
# gppaklo,gppakhi:  shortest,longest time between event-onsets in groups (MS)
# gpranglo,gpranghi:min,max pitchrange grps OR (hfields) no.of hf-notes range
# atten:      overall attenuation of output
# position:   centre of output sound-image (0(Left) 1(Right): default 0.5)
# spread:     spatial-spread of texture events (0 - 1(full-spread))
# seed:       same seed-no: same output on rerun(dflt 0: differs each time)
# -w:         always play whole input-sound (ignore maxdur,mindur vals).
# -d: 		 fixed timestep between groupnotes.
# -i:         each group not confined to a fixed instr (default:fixed)
# 
# 
cdp.texture.add_process("grouped", "sndfile", "sndfile", 5, "Texture of event-groups generated from 1 or more sounds.")
params = []
cdp.texture.grouped.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.grouped.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.grouped.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.grouped.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.grouped.add_mode(5, params, "NEUTRAL")
#
# TEXTURE DECORATED
#
# CDP Release 5 2005
# TEXTURE WITH DECORATIONS:USAGE:texture decorated|predecor|postdecor mode infile
# [infile2..] outfile notedata outdur skiptime sndfirst sndlast mingain maxgain
# mindur maxdur phgrid gpspace gpsprange amprise contour gpsizlo gpsizhi
# gppaklo gppakhi gpranglo gpranghi centring
#               [-aatten] [-ppos] [-ssprd] [-rseed] [-w] [-d] [-i] [-h] [-e] [-k]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:         infofile, 'pitch' of insnds, decoration shape etc.
# outdur:           (min) duration outfile
# skiptime:         time between repets of motif-to-decorate in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max gain on input events (MIDI)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           timegrid (MS) applying WITHIN decors
# gpspace:          spatialisation decor-groups (Range 0-5: default 1)
# gpsprange:        spatial range decor-groups (Range 0-1: default 1)
# amprise:          amplitude change within decors: (0-127: default 0)
# contour:          amplitude contour of decors (Range 0-8: default 0)
# gpsizlo,gpsizhi:  smallest,largest no. events in decors
# gppaklo,gppakhi:  shortest,longest time between event-onsets in decors(MS)
# gpranglo,gpranghi:min,max pitchrange decors OR (hfields) no.of hf-notes range
# centring:         how decor pitches centre on line pitches(Range 0-7:default 0)
# atten:            overall attenuation of output
# pos:              centre of output sound-image (-1(Left) 1(Right): default 0)
# sprd:             spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w: play all insnd(ignore min,maxdur) -h: dec TOPnote chord:(dflt:1st listed)
# -d: fixed timestep btwn decornotes    -e: dec all notes of chords
# -i: instrs vary in decor(dflt:fixed)  -k: discard orig line, after decor
# 
# 
cdp.texture.add_process("decorated", "sndfile", "sndfile", 5, "Texture of decorated events generated from 1 or more sounds")
params = []
cdp.texture.decorated.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.decorated.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.decorated.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.decorated.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.decorated.add_mode(5, params, "NEUTRAL")
#
# TEXTURE MOTIFS
#
# CDP Release 5 2005
# TEXTURE OF MOTIFS, (1ST NOTES ONLY, FORCED ONTO HARMONIC FIELD/SET, IF USED)
# USAGE: texture motifs mode infile [infile2...] outfile notedata outdur packing
# scatter tgrid sndfirst sndlast mingain maxgain mindur maxdur minpich maxpich
# phgrid gpspace gpsprange amprise contour multlo multhi
#                  [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata: infofile, 'pitch' of insnds, timings for timed textures,hfields etc.
# outdur:             (min) duration of outfile
# packing:            (average) time between motif onsets.
# scatter:            randomisation of event-onsets (0 - 10)
# tgrid:              minstep(MS) quantised timegrid (for mtf starttimes)(dflt 0)
# sndfirst,sndlast:   1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:    min & max level of input events (1-127:default 64,64)
# minpich,maxpich:    min & max pitch (MIDI VALUE)
# phgrid:             a timegrid (MS) applying WITHIN the motifs
# gpspace:            spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:          spatial range of event-groups (Range 0-1: default 1)
# amprise:            amplitude change within motifs: (0-127: default 0)
# contour:            amplitude contour of groups (Range 0-6: default 0)
# multlo, multhi:     min & max multiplier of total input duration of motif
# atten:              overall attenuation of the output
# position:           centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:             spatial-spread of texture events (0 - 1(full-spread))
# seed:               same seed-no: same output on rerun(dflt 0: differs each time)
# -w:                 always play whole input-sound (ignoring duration values).
# -d                  notes of any one motif all have same duration.
# -i:                 motif not each confined to fixed instr (default:fixed)
# 
# 
cdp.texture.add_process("motifs", "sndfile", "sndfile", 5, "Texture of user-specified motifs.")
params = []
cdp.texture.motifs.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.motifs.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.motifs.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.motifs.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.motifs.add_mode(5, params, "NEUTRAL")
#
# TEXTURE MOTIFSIN
#
# CDP Release 5 2005
# TEXTURE OF MOTIFS, FORCED ONTO A HARMONIC FIELD: USAGE:
# texture motifsin mode infile [infile2..] outfile notedata outdur packing
# scatter tgrid sndfirst sndlast mingain maxgain mindur maxdur
# minpitch maxpitch phgrid gpspace gpsprange amprise  contour multlo multhi
#                 [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i]
# MODES:-
# 1) ON HARMONIC-FIELD 2) CHANGING HFLDS 3) HARMONIC-SET 4) CHANGING HSETS
# notedata: infofile,'pitch' of insnds, timings for timed textures, hfields etc
# outdur:             (min) duration of outfile
# packing:            (average) time between motif onsets.
# scatter:            randomisation of event-onsets (0 - 10)
# tgrid:              minstep(MS) quantised timegrid (for mtf starttimes)(dflt 0)
# sndfirst,sndlast:   1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:    min & max level of input events (1-127:default 64,64)
# minpitch,maxpitch:  min & max pitch (MIDI VALUE)
# phgrid:             a timegrid (MS) applying WITHIN the motifs
# gpspace:            spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:          spatial range of event-groups (Range 0-1: default 1)
# amprise:            amplitude change within motifs: (0-127: default 0)
# contour:            amplitude contour of groups (Range 0-6: default 0)
# multlo, multhi:     min & max multiplier of total input duration of motif
# atten:              overall attenuation of the output
# position:           centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:             spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:                 always play whole input-sound (ignoring duration values).
# -d                  notes within any one motif all have same duration.
# -i:                 motif not each confined to fixed instr (default:fixed)
# 
# 
cdp.texture.add_process("motifsin", "sndfile", "sndfile", 4, "Texture of user_specified motifs, forced onto harmonic fields.")
params = []
cdp.texture.motifsin.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.motifsin.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.motifsin.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.motifsin.add_mode(4, params, "OVER HARMONIC SETS")
#
# TEXTURE ORNATE
#
# CDP Release 5 2005
# TEXTURE WITH ORNAMENTS: USAGE:
# texture ornate|preornate|postornate mode infile [infile2...] outfile notedata
# outdur skiptime sndfirst sndlast   mingain maxgain  mindur maxdur
# phgrid gpspace gpsprange  amprise  contour   multlo   multhi
#           [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i] [-h] [-e]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:   infofile, 'pitch' of insnds, notes in ornaments, hfields etc.
# outdur:           (min) duration of outfile
# skiptime:         time between repetitions of motif-to-ornament in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max level of input events (1-127:default 64,64)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           a timegrid (MS) applying WITHIN the ornaments
# gpspace:          spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:        spatial range of event-groups (Range 0-1: default 1)
# amprise:          amplitude change within ornaments: (0-127: default 0)
# contour:          amplitude contour of groups (Range 0-8: default 0)
# multlo, multhi:   min & max multiplier of total input duration of motif
# atten:            overall attenuation of the output
# position:         centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# -d:               ornament notes all have same duration as ornamented note
# -i:               orns not confined to instr of ornd-note (default:same note)
# -h:               orns on highest note of any chord:(default:1st note listed)
# -e:               ornaments on all notes of any chord.
# 
# 
cdp.texture.add_process("ornate", "sndfile", "sndfile", 5, "Texture of events with user-specified ornaments.")
params = []
cdp.texture.ornate.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.ornate.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.ornate.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.ornate.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.ornate.add_mode(5, params, "NEUTR")
#
# TEXTURE POSTDECOR
#
# CDP Release 5 2005
# TEXTURE WITH DECORATIONS:USAGE:texture decorated|predecor|postdecor mode infile
# [infile2..] outfile notedata outdur skiptime sndfirst sndlast mingain maxgain
# mindur maxdur phgrid gpspace gpsprange amprise contour gpsizlo gpsizhi
# gppaklo gppakhi gpranglo gpranghi centring
#               [-aatten] [-ppos] [-ssprd] [-rseed] [-w] [-d] [-i] [-h] [-e] [-k]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:         infofile, 'pitch' of insnds, decoration shape etc.
# outdur:           (min) duration outfile
# skiptime:         time between repets of motif-to-decorate in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max gain on input events (MIDI)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           timegrid (MS) applying WITHIN decors
# gpspace:          spatialisation decor-groups (Range 0-5: default 1)
# gpsprange:        spatial range decor-groups (Range 0-1: default 1)
# amprise:          amplitude change within decors: (0-127: default 0)
# contour:          amplitude contour of decors (Range 0-8: default 0)
# gpsizlo,gpsizhi:  smallest,largest no. events in decors
# gppaklo,gppakhi:  shortest,longest time between event-onsets in decors(MS)
# gpranglo,gpranghi:min,max pitchrange decors OR (hfields) no.of hf-notes range
# centring:         how decor pitches centre on line pitches(Range 0-7:default 0)
# atten:            overall attenuation of output
# pos:              centre of output sound-image (-1(Left) 1(Right): default 0)
# sprd:             spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w: play all insnd(ignore min,maxdur) -h: dec TOPnote chord:(dflt:1st listed)
# -d: fixed timestep btwn decornotes    -e: dec all notes of chords
# -i: instrs vary in decor(dflt:fixed)  -k: discard orig line, after decor
# 
# 
cdp.texture.add_process("postdecor", "sndfile", "sndfile", 5, "Texture of post-decorated events generated from 1 or more sounds")
params = []
cdp.texture.postdecor.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.postdecor.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.postdecor.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.postdecor.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.postdecor.add_mode(5, params, "NEUTRAL")
#
# TEXTURE POSTORNATE
#
# CDP Release 5 2005
# TEXTURE WITH ORNAMENTS: USAGE:
# texture ornate|preornate|postornate mode infile [infile2...] outfile notedata
# outdur skiptime sndfirst sndlast   mingain maxgain  mindur maxdur
# phgrid gpspace gpsprange  amprise  contour   multlo   multhi
#           [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i] [-h] [-e]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:   infofile, 'pitch' of insnds, notes in ornaments, hfields etc.
# outdur:           (min) duration of outfile
# skiptime:         time between repetitions of motif-to-ornament in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max level of input events (1-127:default 64,64)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           a timegrid (MS) applying WITHIN the ornaments
# gpspace:          spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:        spatial range of event-groups (Range 0-1: default 1)
# amprise:          amplitude change within ornaments: (0-127: default 0)
# contour:          amplitude contour of groups (Range 0-8: default 0)
# multlo, multhi:   min & max multiplier of total input duration of motif
# atten:            overall attenuation of the output
# position:         centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# -d:               ornament notes all have same duration as ornamented note
# -i:               orns not confined to instr of ornd-note (default:same note)
# -h:               orns on highest note of any chord:(default:1st note listed)
# -e:               ornaments on all notes of any chord.
# 
# 
cdp.texture.add_process("postornate", "sndfile", "sndfile", 5, "Texture of events with user-specified post-ornaments.")
params = []
cdp.texture.postornate.add_mode(1, params, "OVER HARMONIC FIELD (1) OVER HARMONIC FIELD")
params = []
cdp.texture.postornate.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.postornate.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.postornate.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.postornate.add_mode(5, params, "NEUTRAL")
#
# TEXTURE PREDECOR
#
# CDP Release 5 2005
# TEXTURE WITH DECORATIONS:USAGE:texture decorated|predecor|postdecor mode infile
# [infile2..] outfile notedata outdur skiptime sndfirst sndlast mingain maxgain
# mindur maxdur phgrid gpspace gpsprange amprise contour gpsizlo gpsizhi
# gppaklo gppakhi gpranglo gpranghi centring
#               [-aatten] [-ppos] [-ssprd] [-rseed] [-w] [-d] [-i] [-h] [-e] [-k]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:         infofile, 'pitch' of insnds, decoration shape etc.
# outdur:           (min) duration outfile
# skiptime:         time between repets of motif-to-decorate in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max gain on input events (MIDI)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           timegrid (MS) applying WITHIN decors
# gpspace:          spatialisation decor-groups (Range 0-5: default 1)
# gpsprange:        spatial range decor-groups (Range 0-1: default 1)
# amprise:          amplitude change within decors: (0-127: default 0)
# contour:          amplitude contour of decors (Range 0-8: default 0)
# gpsizlo,gpsizhi:  smallest,largest no. events in decors
# gppaklo,gppakhi:  shortest,longest time between event-onsets in decors(MS)
# gpranglo,gpranghi:min,max pitchrange decors OR (hfields) no.of hf-notes range
# centring:         how decor pitches centre on line pitches(Range 0-7:default 0)
# atten:            overall attenuation of output
# pos:              centre of output sound-image (-1(Left) 1(Right): default 0)
# sprd:             spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w: play all insnd(ignore min,maxdur) -h: dec TOPnote chord:(dflt:1st listed)
# -d: fixed timestep btwn decornotes    -e: dec all notes of chords
# -i: instrs vary in decor(dflt:fixed)  -k: discard orig line, after decor
# 
# 
cdp.texture.add_process("predecor", "sndfile", "sndfile", 5, "Texture of pre-decorated events generated from 1 or more sounds")
params = []
cdp.texture.predecor.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.predecor.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.predecor.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.predecor.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.predecor.add_mode(5, params, "NEUTRAL")
#
# TEXTURE PREORNATE
#
# CDP Release 5 2005
# TEXTURE WITH ORNAMENTS: USAGE:
# texture ornate|preornate|postornate mode infile [infile2...] outfile notedata
# outdur skiptime sndfirst sndlast   mingain maxgain  mindur maxdur
# phgrid gpspace gpsprange  amprise  contour   multlo   multhi
#           [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i] [-h] [-e]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:   infofile, 'pitch' of insnds, notes in ornaments, hfields etc.
# outdur:           (min) duration of outfile
# skiptime:         time between repetitions of motif-to-ornament in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  min & max level of input events (1-127:default 64,64)
# mindur,maxdur:    min & max duration of events in texture
# phgrid:           a timegrid (MS) applying WITHIN the ornaments
# gpspace:          spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:        spatial range of event-groups (Range 0-1: default 1)
# amprise:          amplitude change within ornaments: (0-127: default 0)
# contour:          amplitude contour of groups (Range 0-8: default 0)
# multlo, multhi:   min & max multiplier of total input duration of motif
# atten:            overall attenuation of the output
# position:         centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# -d:               ornament notes all have same duration as ornamented note
# -i:               orns not confined to instr of ornd-note (default:same note)
# -h:               orns on highest note of any chord:(default:1st note listed)
# -e:               ornaments on all notes of any chord.
# 
# 
cdp.texture.add_process("preornate", "sndfile", "sndfile", 5, "Texture of events with user-specified pre-ornaments.")
params = []
cdp.texture.preornate.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.preornate.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.preornate.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.preornate.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.preornate.add_mode(5, params, "NEUTRAL")
#
# TEXTURE TIMED
#
# CDP Release 5 2005
# TIMED TEXTURE:  USAGE:
# texture timed mode infile [infile2...]  outfile  notedata     outdur skiptime
#              sndfirst sndlast mingain maxgain mindur maxdur minpitch maxpitch
#              [-aatten] [-pposition] [-sspread] [-rseed] [-w]
# MODES:-
# 1)  ON A GIVEN HARMONIC-FIELD        3)  ON A GIVEN HARMONIC-SET
# 2)  ON CHANGING HARMONIC-FIELDS      4)  ON CHANGING HARMONIC-SETS
# 5)  NONE
# notedata: infofile, insnd 'pitches',texture timing,harmonic fields pitches etc.
# outdur:            (min) duration of outfile
# skiptime:          time between repetitions of timing motif in notedata
# sndfirst,sndlast:  1st,last snd to use,from list of insnds(range:1 - all)
# mingain,maxgain:   min & max level of input events (1-127:default 64,64)
# mindur,maxdur:     min & max duration of events in texture
# minpitch,maxpitch: min & max pitch (MIDI VALUE)
# atten:             overall attenuation of the output
# position:          centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:            spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:                always play whole input-sound (ignoring duration values).
# 
# 
cdp.texture.add_process("timed", "sndfile", "sndfile", 5, "Texture of timed events.")
params = []
cdp.texture.timed.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.timed.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.timed.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.timed.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.timed.add_mode(5, params, "NEUTRAL")
#
# TEXTURE TGROUPED
#
# CDP Release 5 2005
# TIMED TEXTURE OF EVENT-GROUPS: USAGE: texture tgrouped mode infile [infile2..]
# outfile notedata outdur skip sndfirst sndlast mingain maxgain mindur maxdur
# minpitch maxpitch phgrid gpspace gpsprange amprise contour gpsizelo gpsizehi
# gppacklo gppackhi gpranglo gpranghi
#                    [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d] [-i]
# MODES:-
# 1)  ON A GIVEN HARMONIC-FIELD        3)  ON A GIVEN HARMONIC-SET
# 2)  ON CHANGING HARMONIC-FIELDS      4)  ON CHANGING HARMONIC-SETS
# 5)  NONE
# notedata: infofile, 'pitch' of insnds, timings for timed textures, hfields etc
# outdur:           (min) duration of outfile
# skip:             time between repetitions of timing motif in notedata
# sndfirst,sndlast: 1st,last snd to use from list of insnds(range:1 - all)
# mingain,maxgain:  min & max level of input events (1-127:default 64,64)
# mindur,maxdur:    min & max duration of events in texture
# minpitch,maxpitch:min & max pitch (MIDI VALUE)
# phgrid:           timegrid (MS) applying WITHIN the groups
# gpspace:          spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:        spatial range of event-groups (Range 0-1: default 1)
# amprise:          amplitude change within groups: (0-127: default 0)
# contour:          amplitude contour of groups (Range 0-6: default 0)
# gpsizelo,gpsizehi:smallest & largest numbers of events in groups
# gppacklo,gppackhi:shortest & longest time between event-onsets in groups (MS)
# gpranglo,gpranghi:min,max pitchrange grps OR (hfields) no.of hf-notes range
# atten:            overall attenuation of output
# position:         centre of output sound-image (0(Left) 1(Right): default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# -d: 				fixed timestep between groupnotes.
# -i:               each group not confined to a fixed instr (default:fixed)
# 
# 
cdp.texture.add_process("tgrouped", "sndfile", "sndfile", 5, "Texture of timed event-groups.")
params = []
cdp.texture.tgrouped.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.tgrouped.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.tgrouped.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.tgrouped.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.tgrouped.add_mode(5, params, "NEUTRAL")
#
# TEXTURE TMOTIFS
#
# CDP Release 5 2005
# TIMED TEXTURE OF MOTIFS, THEMSELVES NOT FORCED ONTO HARMONIC FIELD: USAGE:
# texture tmotifs mode infile [infile2...] outfile notedata outdur skip
# sndfirst sndlast mingain maxgain mindur maxdur minpitch maxpitch phgrid
# gpspace gpsprange amprise contour multlo multhi
#                     [-aatten] [-pposition] [-sspread] [-rseed] [-w] [-d]
# MODES:-
# 1)ON HARMONIC-FIELD 2)CHANGING HFLDS 3)HARMONIC-SET 4)CHANGING HSETS 5)NONE
# notedata:  infofile, 'pitch' of insnds,texture timings,motifs,hfields etc....
# outdur:             (min) duration of outfile
# skip:               time between repetitions of timing motif in notedata
# sndfirst,sndlast:   1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:    min & max level of input events (1-127:default 64,64)
# minpitch,maxpitch:  min & max pitch (MIDI VALUE)
# phgrid:             a timegrid (MS) applying WITHIN the motifs
# gpspace:            spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:          spatial range of event-groups (Range 0-1: default 1)
# amprise:            amplitude change within motifs: (0-127: default 0)
# contour:            amplitude contour of groups (Range 0-6: default 0)
# multlo, multhi:     min & max multiplier of total input duration of motif
# atten:              overall attenuation of the output
# position:           centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:             spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:                 always play whole input-sound (ignoring duration values).
# -d:                 motif notes all have same duration as ornamented note
# -i:                 motif not each confined to fixed instr (default:fixed)
# 
# 
cdp.texture.add_process("tmotifs", "sndfile", "sndfile", 5, "Texture of user-specified timed motifs.")
params = []
cdp.texture.tmotifs.add_mode(1, params, "OVER HARMONIC FIELD")
params = []
cdp.texture.tmotifs.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.tmotifs.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.tmotifs.add_mode(4, params, "OVER HARMONIC SETS")
params = []
cdp.texture.tmotifs.add_mode(5, params, "NEUTRAL")
#
# TEXTURE TMOTIFSIN
#
# CDP Release 5 2005
# TIMED TEXTURE OF MOTIFS, FORCED ONTO A HARMONIC FIELD: USAGE:
# texture tmotifsin mode infile [infile2...] outfile notedata sndfirst sndlast
# mingain maxgain mindur maxdur minpich maxpich phgrid gpspace gpsprange
# amprise contour multlo multhi [-aatten] [-ppos] [-sspread] [-rseed] [-w] [-d]
# MODES:-
# 1) ON HARMONIC-FIELD 2) CHANGING HFLDS 3) HARMONIC-SET 4) CHANGING HSETS
# notedata:    infofile, 'pitch' of insnds,motifs,texture timings,hfields etc..
# outdur:           (min) duration of outfile
# skiptime:         time between repetitions of timing motif in notedata
# sndfirst,sndlast: 1st,last snd to use, from input snds (range 1 - all)
# mingain,maxgain:  minimum & maximum level of input events (1-127:default 64,64)
# minpich,maxpich:  min & max pitch (MIDI VALUE)
# phgrid:           a timegrid (MS) applying WITHIN the motifs
# gpspace:          spatialisation of event-groups (Range 0-5: default 1)
# gpsprange:        spatial range of event-groups (Range 0-1: default 1)
# amprise:          amplitude change within motifs: (0-127: default 0)
# contour:          amplitude contour of groups (Range 0-6: default 0)
# multlo, multhi:   min & max multiplier of total input duration of motif
# atten:            overall attenuation of the output
# pos:              centre of output sound-image (0(Left) 1(Right):default 0.5)
# spread:           spatial-spread of texture events (0 - 1(full-spread))
# seed:             same seed-no: same output on rerun(dflt 0: differs each time)
# -w:               always play whole input-sound (ignoring duration values).
# -d:               notes in any one motif all have same duration as timing note.
# -i:               motifs not each confined to a fixed instrument (default: fixed)
# 
# 
cdp.texture.add_process("tmotifsin", "sndfile", "sndfile", 4, "Texture of user-specified timed motifs, forced on Harmonic Field.")
params = []
cdp.texture.tmotifsin.add_mode(1, params, "OVER HARMONIC FIE")
params = []
cdp.texture.tmotifsin.add_mode(2, params, "OVER HARMONIC FIELDS")
params = []
cdp.texture.tmotifsin.add_mode(3, params, "OVER HARMONIC SET")
params = []
cdp.texture.tmotifsin.add_mode(4, params, "OVER HARMONIC SETS")
#
# DISTORT
#
#
# DISTORT AVERAGE
#
# CDP Release 5 2005
# USAGE:
# distort average infile outfile cyclecnt [-mmaxwavelen] [-sskipcycles]
# 
# AVERAGE THE WAVESHAPE OVER N 'WAVECYCLES'
# 
# CYCLECNT   is number of cycles to average over ( > 1)
# MAXWAVELEN is max permissible wavelength in seconds. (default 0.50)
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# 
cdp.distort.add_process("average", "sndfile", "sndfile", None, "Average the waveshape over N wavecycles.")
params = [
            ["cyclecnt", 1, None, "number of cycles to average over ( > 1)"],
            ["-m", 2, None, "number of cycles to average over ( > 1)"],
            ["-s", 0, None, "(integer) number of 'wavecycles' to skip at start of file"]
        ]
cdp.distort.average.add_parameters(params)
#
# DISTORT CYCLECNT
#
# CDP Release 5 2005
# USAGE:
# distort cyclecnt infile
# 
# COUNT 'WAVECYCLES' IN SNDFILE.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("cyclecnt", "sndfile", "sndfile", None, "Count pseudo-wavecycles in soundfile.")
params = [
        ]
cdp.distort.cyclecnt.add_parameters(params)
cdp.distort.cyclecnt.note = "This returns an integer, nothing uses this data at the moment."
#
# DISTORT DELETE
#
# CDP Release 5 2005
# USAGE:
# distort delete mode infile outfile cyclecnt [-sskipcycles]
# 
# TIMECONTRACT FILE BY DELETING 'WAVECYCLES'
# 
# MODES:
# 1:  1 in CYCLECNT wavecycles retained
# 2:  Strongest 1 in CYCLECNT wavecycles retained
# 
# 3:  Weakest 1 in CYCLECNT wavecycles deleted
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("delete", "sndfile", "sndfile", 3, "Time-contract file by deleting wavecycles.")
params = [
            ["cyclecnt", 1, None, "groups of 'wavecycles': really the level of resolution at which the process will work"],
            ["-s", 0, None, "(integer) number of 'wavecycles' to skip at start of file"]
         ]
cdp.distort.delete.add_mode(1, params, "IN GIVEN ORDER")
cdp.distort.delete.add_mode(2, params, "RETAIN LOUDEST")
cdp.distort.delete.add_mode(3, params, "DELETE WEAKEST")

#
# DISTORT DIVIDE
#
# CDP Release 5 2005
# USAGE:
# distort divide infile outfile N [-i]
# 
# DISTORTION BY DIVIDING 'WAVECYCLE' FREQUENCY.
# 
# N = divider (integer only: range 2-16)
# -i uses waveform interpolation: slower, but cleaner.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("divide", "sndfile", "sndfile", None, "Divide wavecycle 'frequencies'.")
params = [
        ["N", 2, 16, "divider"],
        ["-i", 1, 1, "uses waveform interpolation: slower, but cleaner"]
        ]
cdp.distort.divide.add_parameters(params)
#
# DISTORT ENVEL
#
# CDP Release 5 2005
# USAGE:
# distort envel 1-2 infile outfile         cyclecnt [-ttroughing] [-eexponent]
# distort envel 3   infile outfile         cyclecnt troughing     [-eexponent]
# distort envel 4   infile outfile envfile cyclecnt 
# 
# IMPOSE ENVELOPE OVER EACH GROUP OF cyclecnt 'WAVECYCLES'
# 
# MODES (Works on MONO files only)-
# 1  rising envelope.
# 2  falling envelope.
# 3  troughed envelope.
# 4  user defined envelope.
# CYCLECNT  is no of wavecycles under a single envelope.
# EXPONENT  is exponent for envelope rise or decay:
#           If OMMITED envelope rise/decay is linear.
# TROUGHING is trough of envelope (0-1: default 0).
# ENVFILE   Defines user envelope as time/val(0-1) pairs.
#           (Time units arbitrary, as envelope stretched to each cycle(set) duration.
# 
# CYCLECNT, TROUGHING and EXPONENT, may vary over time
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("envel", "sndfile", "sndfile", 4, "Impose envelope over each (group of) wavecycle(s).")
params = [
        ["cyclecnt", 1, None, "no of wavecycles under a single envelope"],
        ["-t", 0, 1, "trough of envelope"],
        ["-e", 0, None, "exponent for envelope rise or decay. if OMMITED envelope rise/decay is linear"]
        ]
cdp.distort.envel.add_mode(1, params, "RISING")
cdp.distort.envel.add_mode(2, params, "FALLING")
params = [
        ["cyclecnt", 1, None, "no of wavecycles under a single envelope"],
        ["troughing", 0, 1, "trough of envelope"],
        ["-e", 0, None, "exponent for envelope rise or decay. if OMMITED envelope rise/decay is linear"]
        ]
cdp.distort.envel.add_mode(3, params, "TROUGHED")
params = [
        ["envfile", None, None, "defines user envelope as time/val(0-1) pairs. (Time units arbitrary, as envelope stretched to each cycle(set) duration."],
        ["cyclecnt", 1, None, "no of wavecycles under a single envelope"],
        ]
cdp.distort.envel.add_mode(4, params, "USER DEFINED")
#
# DISTORT FILTER
#
# CDP Release 5 2005
# USAGE:
# distort filter 1-2 infile outfile freq        [-sskipcycles]
# distort filter 3   infile outfile freq1 freq2 [-sskipcycles]
# 
# TIMECONTRACT SOUND BY FILTERING OUT 'WAVECYCLES'
# 
# MODES:
# 1:  omit cycles below FREQ
# 2:  omit cycles above FREQ
# 3:  omit cycles below FREQ1 and above FREQ2
# 
# skipcycles: (integer) is no. of wavecycles to skip at start of file
# 
# freq, freq1 and freq2 may vary over time.
# 
# N.B. timevarying freq1, freq2 may not cross each other, nor be equal.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("filter", "sndfile", "sndfile", 3, "Remove wavecycles of certain lengths.")
params = []
cdp.distort.filter.add_mode(1, params, "HIGH PASS")
params = []
cdp.distort.filter.add_mode(2, params, "LOW PASS")
params = []
cdp.distort.filter.add_mode(3, params, "BAND PASS")
#
# DISTORT FRACTAL
#
# CDP Release 5 2005
# USAGE:
# distort fractal infile outfile scaling loudness [-ppre_attenuation]
# 
# SUPERIMPOSE MINIATURE COPIES OF SRC 'WAVECYCLES' ONTO THEMSELVES.
# 
# SCALING  = (integer) division of scale of src wave (range: 2 to 0.50*srate)
# LOUDNESS = loudness of scaled component, relative to src (loudness 1.0).
# 
# PRE_ATTENUATION is applied to input sound before processing.
# 
# scaling and loudness may vary over time
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("fractal", "sndfile", "sndfile", None, "Superimpose miniature copies of wavecycles onto themselves.")
params = [
        ["scaling", 2, SAMPLE_RATE/2, "(integer) division of scale of src wave (range: 2 to 0.50*srate) (may vary over time)"],
        ["loudness", 0.0, 1.0, "loudness of scaled component, relative to src (loudness 1.0). (may vary over time)"],
        ["-p", 0.0, None, "PRE_ATTENUATION is applied to input sound before processing."]
        ]
cdp.distort.fractal.add_parameters(params)
#
# DISTORT HARMONIC
#
# CDP Release 5 2005
# USAGE:
# distort harmonic infile outfile harmonics-file [-ppre_attenuation]
# 
# HARMONIC DISTORTION BY SUPERIMPOSING 'HARMONICS' ONTO 'WAVECYCLES'.
# 
# HARMONICS-FILE contains harmonic_no/amplitude pairs.
#     where amplitude of src sound is taken to be 1.0
#     and harmonics range between 2 and 1024
# 
# PRE_ATTENUATION is applied to input sound before processing.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("harmonic", "sndfile", "sndfile", None, "Superimpose 'harmonics' onto wavecycles.")
params = [
        ["harmonics_file", "", "", "contains harmonic_no/amplitude pairs. where amplitude of src sound is taken to be 1.0 and harmonics range between 2 and 1024"],
        ["-p", 0.0, None, "PRE_ATTENUATION is applied to input sound before processing."]
        ]
cdp.distort.harmonic.add_parameters(params)
#
# DISTORT INTERACT
#
# CDP Release 5 2005
# USAGE:
# distort interact mode infile1 infile2 outfile
# 
# TIME-DOMAIN INTERACTION OF SOUNDS.
# 
# MODES:
# 1:  interleave wavecycles from the two infiles.
# 2:  impose wavecycle-lengths of 1st file on wavecycles of 2nd
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("interact", "sndfile2", "sndfile", None, "Interaction of wavecycles of two sounds.")
#cdp.distort.add_process("interact", "sndfile2", "sndfile", 2, "Interaction of wavecycles of two sounds.")
"""
params = []
cdp.distort.interact.add_mode(1, params, "INTERLEAVE")
params = []
cdp.distort.interact.add_mode(2, params, "RESIZE")
"""
params = []
cdp.distort.interact.add_parameters(params)

cdp.distort.interact.note = "No support for two infiles yet."
#
# DISTORT INTERPOLATE
#
# CDP Release 5 2005
# USAGE:
# distort interpolate infile outfile multiplier [-sskipcycles]
# 
# TIMESTRETCH FILE BY REPEATING 'WAVECYCLES' & INTERPOLATING BETWEEN THEM.
# 
# MULTIPLIER: (integer) is no. of times each wavecycle repeats.
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# multiplier and cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("interpolate", "sndfile", "sndfile", None, "Hold wavecycle for N cycles,interpolating to shape of next.")
params = [
        ["multiplier", 0, None, "(integer) number of times each 'wavecycle' repeats (may vary over time)"],
        ["-s", 0, None,         "(integer) number of 'wavecycles' to skip at start of file"]
        ]
cdp.distort.interpolate.add_parameters(params)
#
# DISTORT MULTIPLY
#
# CDP Release 5 2005
# USAGE:
# distort multiply infile outfile N [-s]
# 
# DISTORTION BY MULTIPLYING 'WAVECYCLE' FREQUENCY.
# 
# N = multiplier (integer only: range 2-16)
# -s smoothing: try if glitches appear.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("multiply", "sndfile", "sndfile", None, "Multiply wavecycle 'frequencies'.")
params = [
        ["N", 2, 16,         "multiplier (integer: range 2-16)"],
        ["-s", 0, None,         "smoothing: try if glitches appear."]
        ]
cdp.distort.multiply.add_parameters(params)
#
# DISTORT OMIT
#
# CDP Release 5 2005
# USAGE:
# distort omit infile outfile A B
# 
# OMIT A OUT OF EVERY B 'WAVECYCLES' REPLACING THEM BY SILENCE
# 
# A may vary over time: but must always be less than B.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("omit", "sndfile", "sndfile", None, "Omit A out of every B wavecycles, replacing them by silence.")
params = [
        ["A", 0, None, "number of wavecycles to omit"],
        ["B", 0, None, "size of group of 'wavecycles' out of which to omit A 'wavecycles'"],
        ]
cdp.distort.omit.add_parameters(params)
#
# DISTORT OVERLOAD
#
# CDP Release 5 2005
# USAGE:
# distort overload 1 infile outfile clip_level depth
# OR
# distort overload 2 infile outfile gate depth freq
# 
# Clip the signal with noise or a (possibly timevarying) waveform.
# 
# clip_level: Level at which the signal is clipped.
#             Range(0 - 1)
# depth:      Depth of distortion pattern on clipped stretches of signal.
#             (Range 0 - 1)
# freq:       Frequency of waveform imposed on clipped stretches of signal.
# 
# clip_level, depth and freq may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("overload", "sndfile", "sndfile", 2, "Clip signal with noise or a (timevarying) waveform.")
params = []
cdp.distort.overload.add_mode(1, params, "CLIP THE SIGNAL WITH NOISE")
params = []
cdp.distort.overload.add_mode(2, params, "CLIP WITH WAVEFORM")
#
# DISTORT PITCH
#
# CDP Release 5 2005
# USAGE:
# distort pitch infile outfile octvary [-ccyclelen] [-sskipcycles]
# 
# PITCHWARP 'WAVECYCLES' OF SOUND.
# 
# octvary:    max possible transposition (up or down) in octaves.
#             Range(>0 - 8.0)
#             pitch of each wavecycle is varied by a random amount
#             within the range octvary 8vas up to octvary 8vas down.
# cylelen:    Max no. cycles possible between generation of transpos vals(>1)
#             (Default : 64)
#             Actual cyclecnt is a random number, less than this maximum.
# skipcycles: No of cycles to skip at start of file.
# 
# cyclelen and octvary may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("pitch", "sndfile", "sndfile", None, "Pitchwarp wavecycles of sound.")
params = [
            ["octvary", 0.001, 8.0, "maximum possible transposition up or down in (fractions of) octaves (Range > 0.0 to 8.0)"],
            ["-c", 0, None,         "mamimum number of 'wavecycles' between the generation of transposition values (Range: > 1, Default: 64)"],
            ["-s", 0, None,         "(integer) number of 'wavecycles' to skip at start of file"]
         ]
cdp.distort.pitch.add_parameters(params)
#
# DISTORT PULSED
#
# CDP Release 5 2005
# USAGE:
# distort pulsed
# 1 infil outfil env stime dur frq frand trand arand transp tranrand [-s -e]
# OR
# 2-3 inf outf env stime dur frq frand trand arand cyctime transp tranrand [-s -e]
#     Impose impulse-train on source (mode 1), OR
#     Use segment of src as looped content of synthetic impulse-train(modes 2,3).
# ENV        brkpnt envelope of impulse. Will be scaled to duration needed.
# STIME      time in src sound where impulses begin.(In mode 3,time as samplecnt)
# DUR        time for which impulses persist.
# FRQ        frequency of the impulses, in Hz: range 0.1 to 50
# FRAND      randomisation of frequency of impulse (in semitones) (range 0-12).
# TRAND      randomisation of relative time-positions of amp peaks & troughs
#            from impulse to impulse. (range 0 - 1)
# ARAND      randomisation of amplitude shape created by peaks & troughs
#            from impulse to impulse. (range 0 - 1)
# CYCTIME    duration of wavecycles to grab for sound inside impulses (mode 2)
#            OR number of wavecycles to grab as sound inside impulses (mode 3)
# TRANSP     transposition contour of sound inside each impulse. Brkpnt file of
#            time:semitone-shift pairs,(time will be scaled to impulse dur),
# TRANRAND   randomisation transp contour from impulse to impulse.(Range 0-1)
# -s         keep start of src sound, before impulses begin (if any).
# -e         keep end of src sound, after impulses end (if any)
# Works on MONO files only
# 
# 
cdp.distort.add_process("pulsed", "sndfile", "sndfile", 3, "Impose regular pulsations on a sound.")
# 1 infil outfil env stime dur frq frand trand arand transp tranrand [-s -e]
params = [
        ["env", None, None, "brkpnt envelope of impulse. Will be scaled to duration needed."],
        ["stime", 0, None, "time in src sound where impulses begin.(In mode 3, time as samplecnt)."],
        ["dur", 0, None, "time for which impulses persist"],
        ["frq", 0.1, 50, "requency of the impulses, in Hz: range 0.1 to 50"],
        ["frand", 0, 12, "randomisation of frequency of impulse (in semitones) (range 0-12)."],
        ["trand", 0, 1, "randomisation of relative time-positions of amp peaks & troughs from impulse to impulse. (range 0 - 1)."],
        ["arand", 0, 1, "randomisation of amplitude shape created by peaks & troughs from impulse to impulse. range (0 - 1)"],
        ["transp", 0, None, "transposition contour of sound inside each impulse. Brkpnt file of time:semitone-shift pairs,(time will be scaled to impulse dur)."],
        ["tranrand", 0, None, "randomisation transp contour from impulse to impulse.(Range 0-1)"],
        ["-s", 1, 1, "keep start of src sound, before impulses begin (if any)"],
        ["-e", 1, 1, "keep end of src sound, after impulses end (if any)"]
        ]
cdp.distort.pulsed.add_mode(1, params)
params = [
        ["env", None, None, "brkpnt envelope of impulse. Will be scaled to duration needed."],
        ["stime", 0, None, "time in src sound where impulses begin.(In mode 3, time as samplecnt)."],
        ["dur", 0, None, "time for which impulses persist"],
        ["frq", 0.1, 50, "requency of the impulses, in Hz: range 0.1 to 50"],
        ["frand", 0, 12, "randomisation of frequency of impulse (in semitones) (range 0-12)."],
        ["trand", 0, 1, "randomisation of relative time-positions of amp peaks & troughs from impulse to impulse. (range 0 - 1)."],
        ["arand", 0, 1, "randomisation of amplitude shape created by peaks & troughs from impulse to impulse. range (0 - 1)"],
        ["cyctime", 1, 500, "duration of wavecycles to grab for sound inside impulses (mode 2) OR number of wavecycles to grab as sound inside impulses (mode 3)"],
        ["transp", 0, None, "transposition contour of sound inside each impulse. Brkpnt file of time:semitone-shift pairs,(time will be scaled to impulse dur)."],
        ["tranrand", 0, None, "randomisation transp contour from impulse to impulse.(Range 0-1)"],
        ["-s", 1, 1, "keep start of src sound, before impulses begin (if any)"],
        ["-e", 1, 1, "keep end of src sound, after impulses end (if any)"]
        ]
cdp.distort.pulsed.add_mode(2, params)
cdp.distort.pulsed.add_mode(3, params)
#
# DISTORT REFORM
#
# CDP Release 5 2005
# USAGE:
# distort reform 1-7 infile outfile 
# distort reform 8   infile outfile  exaggeration
# 
#  MODIFY SHAPE OF 'WAVECYCLES'
# 
# MODES ARE
# 1 Convert to fixed level square_wave
# 2 Convert to square wave
# 3 Convert to fixed level triangular wave
# 4 Convert to triangular wave
# 5 Convert to inverted half_cycles
# 6 Convert to click stream
# 7 Convert to sinusoid
# 8 Exaggerate waveform contour
# 
# EXAGGERATION may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("reform", "sndfile", "sndfile", 8, "Modify shape of wavecycles.")
params = None
cdp.distort.reform.add_mode(1, params, "FIXED LEVEL SQUARE")
params = None
cdp.distort.reform.add_mode(2, params, "SQUARE")
params = None
cdp.distort.reform.add_mode(3, params, "FIXED LEVEL TRIANGLE")
params = None
cdp.distort.reform.add_mode(4, params, "TRIANGLE")
params = None
cdp.distort.reform.add_mode(5, params, "INVERT HALFCYCLES")
params = None
cdp.distort.reform.add_mode(6, params, "CLICK")
params = None 
cdp.distort.reform.add_mode(7, params, "SINE")
params = [["exaggeration", 0.000002, 40.0, "Exaggeration"]]
cdp.distort.reform.add_mode(8, params, "EXAGGERATE CONTOUR")
#
# DISTORT REPEAT
#
# CDP Release 5 2005
# USAGE:
# distort repeat infile outfile multiplier [-ccyleccnt] [-sskipcycles]
# 
# TIMESTRETCH FILE BY REPEATING 'WAVECYCLES'
# 
# MULTIPLIER: (integer) is no. of times each wavecycle(grp) repeats.
# CYCLECNT:   (integer) is no. wavecycles in repeated groups.
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# multiplier and cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("repeat", "sndfile", "sndfile", None, "Timestretch file by repeating wavecycles.")
params = [
        ["multiplier", 1, None, "(integer) no. of times each wavecycle(grp) repeats."],
        ["-c", 1, None, "(integer) no. of wavecycles in repeated groups."],
        ["-s", 1, None, "(integer) no. of wavecycles to skip at start of file."]
        ]
cdp.distort.repeat.add_parameters(params)
#
# DISTORT REPEAT2
#
# CDP Release 5 2005
# USAGE:
# distort repeat2 infile outfile multiplier [-ccyleccnt] [-sskipcycles]
# 
# REPEATING 'WAVECYCLES' WITHOUT TIME STRETCHING
# 
# MULTIPLIER: (integer) is no. of times each wavecycle(grp) repeats.
# CYCLECNT:   (integer) is no. wavecycles in repeated groups.
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# multiplier and cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("repeat2", "sndfile", "sndfile", None, "Repeat wavecycles without time-stretching.")
params = [
        ["multiplier", 1, None, "(integer) no. of times each wavecycle(grp) repeats."],
        ["-c", 1, None, "(integer) no. of wavecycles in repeated groups."],
        ["-s", 1, None, "(integer) no. of wavecycles to skip at start of file."]
        ]
cdp.distort.repeat2.add_parameters(params)
#
# DISTORT REPLACE
#
# CDP Release 5 2005
# USAGE:
# distort replace infile outfile cyclecnt [-sskipcycles]
# 
# STRONGEST 'WAVECYCLE', IN EACH cyclecnt, REPLACES OTHERS
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("replace", "sndfile", "sndfile", None, "Strongest wavecycle, in each wavecycle group, replaces others.")
params = [
        ["cyclecnt", 0, None, "(integer) size of group of 'wavecycles'. May vary over time."],
        ["-s", 1, None, "no. of wavecycles to skip at start of file."]
        ]
cdp.distort.replace.add_parameters(params)
#
# DISTORT REPLIM
#
# CDP Release 5 2005
# USAGE:
# distort replim inf outf multiplier [-ccyleccnt] [-sskipcycles] -f[hilim]
# 
# TIMESTRETCH FILE BY REPEATING 'WAVECYCLES' (BELOW SPECIFIED FRQ)
# 
# MULTIPLIER: (integer) is no. of times each wavecycle(grp) repeats.
# CYCLECNT:   (integer) is no. wavecycles in repeated groups.
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# HILIM:      (float)   is frq below which cycles are counted.
# 
# multiplier and cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("replim", "sndfile", "sndfile", None, "Timestretch by repeating ‘wavecycles’ (below a specified frequency).")
params = [
        ["multiplier", 1, None, "(integer) no. of times each wavecycle(grp) repeats."],
        ["-c", 1, None, "(integer) no. of wavecycles in repeated groups."],
        ["-s", 1, None, "(integer) no. of wavecycles to skip at start of file."],
        ["-f", 1, 44100, "(float) frq below which cycles are counted."]
        ]
cdp.distort.replim.add_parameters(params)
#
# DISTORT REVERSE
#
# CDP Release 5 2005
# USAGE:
# distort reverse infile outfile cyclecnt
# 
# CYCLE_REVERSAL DISTORTION.'WAVECYCLES' REVERSED IN GROUPS.
# 
# CYCLECNT: no. of cycles (>0) in reversed groups.
# 
# cyclecnt may vary in time
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("reverse", "sndfile", "sndfile", None, "Reverse wavecycle(s in groups).")
params = [
        ["cyclecnt",  0, None, "(integer) size of group of 'wavecycles'. May vary over time."]
        ]
cdp.distort.reverse.add_parameters(params)
#
# DISTORT SHUFFLE
#
# CDP Release 5 2005
# USAGE:
# distort shuffle infile outfile domain-image [-ccylecnt] [-sskipcycles]
# 
# DISTORTION BY SHUFFLING 'WAVECYCLES'
# 
# DOMAIN  group of letters representing consecutive (groups of) wavecyles.
# IMAGE   group of letters which is some permutation of the domain.
# Items from domain may be reordered, ommitted or duplicated.
#   N.B. DOMAIN and IMAGE must be connected by a DASH (-).
# CYCLECNT is size of wavecycle-groups to operate on. (default 1)
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# 
# Cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("shuffle", "sndfile", "sndfile", None, "Shuffle order of wavecycles.")
params = [
        ["domain-image", "", "", "[group of letters representing consecutive (groups of) wavecycles.]-[group of letters which is some permutation of the domain.]"],
        ["-c", 1, None, "(integer) no. of wavecycles in repeated groups."],
        ["-s", 1, None, "(integer) no. of wavecycles to skip at start of file."]
        ]
cdp.distort.shuffle.add_parameters(params)
#
# DISTORT TELESCOPE
#
# CDP Release 5 2005
# USAGE:
# distort telescope infile outfile cyclecnt [-sskipcycles] [-a]
# 
# TIMECONTRACT SOUND BY TELESCOPING cyclecnt 'WAVECYCLES' TO 1
# 
# SKIPCYCLES: (integer) is no. of wavecycles to skip at start of file
# -a          telescope to average cyclelen.(Default: telescope to longest.)
# 
# cyclecnt may vary over time.
# 
# Works on MONO files only
# 
# 
cdp.distort.add_process("telescope", "sndfile", "sndfile", None, "Time-contract sound by telescoping N wavecycles into 1.")
params = [["cyclecnt", 0, None, "cyclecnt"],
        ["-s", 1, None, "(integer) no. of wavecycles to skip at start of file"],
        ["-a", 0, 1, "telescope to average cyclelen.(Default: telescope to longest.)"]
        ]
cdp.distort.telescope.add_parameters(params)
#
# EXTEND
#
#
# EXTEND BAKTOBAK
#
# CDP Release 5 2005
# JOIN A TIME-REVERSED COPY OF THE SOUND, TO A NORMAL COPY, IN THAT ORDER.
# USAGE:  extend baktobak infile outfile join_time splice-length
# 
# JOIN TIME     Time in src file where join-cut is to be made.
# SPLICE LENGTH (MS) Length of the splice, in milliseconds.
# 
# 
cdp.extend.add_process("baktobak", "sndfile", "sndfile", None, "Join backwards copy to forwards original, in that order.")
params = []
cdp.extend.baktobak.add_parameters(params)
#
# EXTEND DOUBLETS
#
# CDP Release 5 2005
# SPLICE SOURCE INTO SEGMENTS, REPEATING EACH.
# USAGE:  extend doublets infile outfile segdur repets [-s]
# 
# SEGDUR       Duration of segments (can vary through time).
# REPETS       Number of times each segment repeated.
# -s           Outfile tries to stay 'synced' to infile.
# 
# 
cdp.extend.add_process("doublets", "sndfile", "sndfile", None, "Divide a sound into segments that repeat, and splice them together.")
params = []
cdp.extend.doublets.add_parameters(params)
#
# EXTEND DRUNK
#
# CDP Release 5 2005
# SPLICE SEGMENTS OF SRCFILE END-TO-END: START-TIMES (IN SRCFILE) OF SEGS,CHOSEN
# BY 'DRUNKEN-WALK' THROUGH SRCFILE:   IN MODE 2, SRCFILE PLAYS SOBERLY AT HOLDS
# 
# USAGES:
# extend drunk 1 infile outfile outdur locus ambitus step clock
#        [-ssplicelen] [-cclokrand] [-ooverlap] [-rseed]
# 
# extend drunk 2 infile outfile outdur locus ambitus step clock mindrnk maxdrnk
#        [-ssplicelen] [-cclokrand] [-ooverlap] [-rseed] [-llosober] [-hhisober]
# 
# OUTDUR    Total (minimum) duration of output file (secs)
# LOCUS     Time in src around which drunkwalk happens.(secs) CAN MOVE THRO SRC.
# AMBITUS   (half)width of region from within which sound-segments read.(secs).
# STEP      Max length of (random) step between segment-reads (>0.002 secs).
#           (always falls WITHIN ambitus: automatically adjusted where too large)
# CLOCK     Time between segment reads = seg duration (> SPLICELEN * 2).(secs).
# MINDRNK   Min no. cloktiks between sober plays (1 - 32767: Default 10)
# MAXDRNK   Max no. cloktiks between sober plays (1 - 32767: Default 30)
# SPLICELEN in MILLIsecs (default 15ms).
# CLOKRAND  Randomisation of clock-ticks. (Range : 0-1: default 0)
# OVERLAP   Mutual overlap of segments in output. (Range 0 to 0.9900: default 0)
# SEED      Any set value gives REPRODUCIBLE output.
# LOSOBER   Min duration of sober plays (secs) (Range: >0 - infiledur+)
#           If >= infiledur (default): sober plays all go to end of src
# HISOBER   Max duration of sober plays (secs) (Range: >0 - infiledur+)
# 
# all params EXCEPT outdur, splicelen and seed, may vary through time.
# 
# 
# TODO: COME BACK
"""
cdp.extend.add_process("drunk", "sndfile", "sndfile", 2, "Drunken-walk through source file (chosen segments read forwards).")
params = []
cdp.extend.drunk.add_mode(1, params, "COMPLETELY DRUNK")
params = []
cdp.extend.drunk.add_mode(2, params, "SOBER MOMENTS")
"""
#
# EXTEND FREEZE
#
# CDP Release 5 2005
# FREEZE A SEGMENT OF A SOUND BY ITERATION IN A FLUID MANNER
# 
# USAGE: extend freeze 1 infil outfil outduration
#      delay rand pshift ampcut start_of_freeze end [-sseed]
# OR:    extend freeze 2 infil outfil repetitions
#      delay rand pshift ampcut starttime_of_freeze endtime gain [-sseed]
# delay   (average) delay between iterations: <= length of frozen segement.
# rand    delaytime-randomisation: Range 0 - 1
# pshift  max of random pitchshift of each iter: Range 0 - 12 semitones
#         e.g.  2.5 =  2.5 semitones up or down.
# ampcut  max of random amp-reduction on each iter: Range 0-1
# start_of_freeze    Time where frozen segment begins in original sound.
# end                Time where frozen segment ends in original sound.
# seed	 the same seed-number will produce identical output on rerun,
#         (Default: (0) random sequence is different every time).
# 
# 
cdp.extend.add_process("freeze", "sndfile", "sndfile", 2, "Freeze a segment of a sound by iteration in a fluid manner.")
params = []
cdp.extend.freeze.add_mode(1, params, "SPECIFY OUTPUT DURATION")
params = []
cdp.extend.freeze.add_mode(2, params, "SPECIFY NUMBER OF REPEATS")
#
# EXTEND ITERATE
#
# CDP Release 5 2005
# ITERATE AN INPUT SOUND IN A FLUID MANNER
# 
# USAGE: extend iterate 1 infil outfil outduration
#      [-ddelay] [-rrand] [-ppshift] [-aampcut] [-ffade] [-ggain] [-sseed]
# OR:    extend iterate 2 infil outfil repetitions
#      [-ddelay] [-rrand] [-ppshift] [-aampcut] [-ffade] [-ggain] [-sseed]
# 
# delay   (average) delay between iterations. Default: infile duration.
# rand    delaytime-randomisation: Range 0 - 1: Default 0
# pshift  max of random pitchshift of each iter: Range 0 - 12 semitones
#         e.g.  2.5 =  2.5 semitones up or down.
# ampcut  max of random amp-reduction on each iter: Range 0-1: default 0
# fade    (average) amplitude fade beween iters (Range 0 - 1: default 0)
# gain    Overall Gain: Range 0 - 1:
#         special val 0 (default), gives best guess for no distortion.
# seed	 the same seed-number will produce identical output on rerun,
#         (Default: (0) random sequence is different every time).
# 
# 
cdp.extend.add_process("iterate", "sndfile", "sndfile", 2, "Repeat sound with subtle variations.")
params = []
cdp.extend.iterate.add_mode(1, params, "GIVE DURATION")
params = []
cdp.extend.iterate.add_mode(2, params, "GIVE COUNT")
#
# EXTEND LOOP
#
# CDP Release 5 2005
# USAGE:
# extend loop 1 infile outfile     start len    step  [-wsplen] [-sscat] [-b]
# extend loop 2 infile outfile dur start len [-lstep] [-wsplen] [-sscat] [-b]
# extend loop 3 infile outfile cnt start len [-lstep] [-wsplen] [-sscat] [-b]
# 
# LOOP INSIDE SOUNDFILE.
# 
# MODES
# 1: Loop advances in soundfile until soundfile is exhausted.
# 2: Specify outfile duration (shortened if looping reaches end of infile).
# 3: Specify number of loop repeats (reduced if looping reaches end of infile).
# 
# start:   time in infile at which looping process begins.
# dur:     duration of outfile required.
# cnt:     number of loop repeats required.
# len:     length of looped segment (MILLIsecs).
# step:    advance in infile from one loopstart to next (MILLIsecs).
#          NB: Can be ZERO in modes 2 and 3, but NOT in mode 1.
# splen:   length of splice in MILLIsecs (Default 25ms).
# scat:    make step advance irregular, within timeframe given by 'scat'.
# b:       play from beginning of infile (even if looping doesn't begin there).
# 
# 
cdp.extend.add_process("loop", "sndfile", "sndfile", 3, "Loop (repeat [advancing] segments) inside soundfile.")
params = []
cdp.extend.loop.add_mode(1, params, "LOOP ADVANCES TO END")
params = []
cdp.extend.loop.add_mode(2, params, "GIVE OUTPUT LENGTH")
params = []
cdp.extend.loop.add_mode(3, params, "GIVE LOOP REPETITIONS")
#
# EXTEND SCRAMBLE
#
# CDP Release 5 2005
# USAGE:
# extend scramble 1 infile outfile minseglen maxseglen outdur
#                                [-wsplen] [-sseed] [-b] [-e]
# extend scramble 2 infile outfile seglen    scatter   outdur
#                              [-wsplen] [-sseed] [-b] [-e]
# 
# MODES:-
# 1) CUT RANDOM CHUNKS FROM FILE, AND SPLICE END TO END.
# 1) CUT FILE INTO RANDOM CHUNKS AND REARRANGE. REPEAT DIFFERENTLY..ETC
# 
# minseglen: minimum chunksize to cut.
# maxseglen: maximum chunksize to cut. (> minseglen)
# seglen:    average chunksize to cut.
# scatter:   Randomisation of chunk lengths. (>= 0)
#            (cannot be greater than infilesize/chunklen (rounded DOWN))
# outdur:    duration of outfile required (> maxseglen).
# splen:     length of splice in MILLIsecs (Default 25ms).
# seed:      the same seed-number will produce identical output on rerun
#            (Default: (0) random sequence is different every time).
# b:         force start of outfile to be beginning of infile.
# e:         force end of outfile to be end of infile.
# 
# 
cdp.extend.add_process("scramble", "sndfile", "sndfile", 2, "Extend soundfile by scrambling it, and writing any given length.")
params = []
cdp.extend.scramble.add_mode(1, params, "COMPLETELY RANDOM")
params = []
cdp.extend.scramble.add_mode(2, params, "SCRAMBLE SRC:THEN AGAIN")
#
# EXTEND SEQUENCE
#
# CDP Release 5 2005
# PRODUCE SEQUENCE OF INPUT SOUND PLAYED AT TRANSPOSITIONS & TIMES SPECIFIED.
# USAGE:  extend sequence infile outfile sequence-file attenuation
# 
# SEQUENCE-FILE  contains output-time, semitone-transposition, loudness triples.
#                (one for each event in the sequence)
#                where loudness is a loudness multiplier
# ATTENUATION    overall attenuation on source, should output overload.
# 
# 
cdp.extend.add_process("sequence", "sndfile", "sndfile", None, "Produce a sequence from 1 sound, with timed transpositions.")
params = []
cdp.extend.sequence.add_parameters(params)
#
# EXTEND SEQUENCE2
#
# CDP Release 5 2005
# PRODUCE SEQUENCE OF SEVERAL SOUNDS PLAYED AT TRANSPOSITIONS & TIMES SPECIFIED.
# USAGE:  extend sequence2 inf1 inf2 [inf3....] outfile sequence-file attenuation
#         (Input files must all have same number of channels).
# SEQUENCE-FILE  1st line has (possibly notional) midi-pitch of each input snd.
#                All other lines have 5 values...
#                input-sound-number, output-time, midi-pitch, loudness, duration
#                (one for each event in the sequence)
#                Loudness is a loudness multiplier (value 0-1).
#                Duration val can curtail length of event, but cannot extend it.
#                (Max event length = (transposed) duration of sound chosen).
# ATTENUATION    overall attenuation on output.
# 
# 
cdp.extend.add_process("sequence2", "sndfile", "sndfile", None, "Produce a sequence from several sounds, with timed transpositions.")
params = []
cdp.extend.sequence2.add_parameters(params)
#
# EXTEND ZIGZAG
#
# CDP Release 5 2005
# USAGE: extend zigzag 1 infile outfile start end dur minzig
# 	[-ssplicelen] [-mmaxzig] [-rseed]
# 
# OR:    extend zigzag 2 infile outfile timefile [-ssplicelen]
# 
# READ BACK AND FORTH INSIDE SOUNDFILE.
# 
# MODES
# 1:	random zigzags: starts at file start, ends at file end.
# 2: zigzagging follows times supplied by user.
# start:     together with...
# end:       define interval in which times zigzag.
# dur:       is total duration of output sound required.
# minzig:    is min acceptable time between successive zigzag timepoints.
# splicelen: in MILLIsecs (Default 25ms).
# maxzig:    is max acceptable time between successive zigzag timepoints
# seed:      number to generate a replicable random sequence. (>0)
#            entering same number on next program run, generates same sequence.
#            (Default: (0) random sequence is different every time).
# timefile:  text file containing sequence of times to zigzag between.
#            Each step-between-times must be > (3 * splicelen).
#            zigsteps moving in the same (time-)direction will be concatenated.
# 
# 
cdp.extend.add_process("zigzag", "sndfile", "sndfile", 2, "Read soundfile backwards and forwards, as you specify.")
params = []
cdp.extend.zigzag.add_mode(1, params, "RANDOM")
params = []
cdp.extend.zigzag.add_mode(2, params, "USER SPECIFIED")
#
# GRAIN
#
#
# GRAIN ALIGN
#
# CDP Release 5 2005
# SYNCHRONISE GRAIN-ONSETS IN 2nd GRAINY-SOUND
#             WITH THOSE IN THE 1st.
# USAGE:
# grain align infile1 infile2 outfile offset gate2
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# INFILE1 provides grain-onset times.
# INFILE2 provides the actual grains to be retimed.
# OFFSET  add this value (secs) to ALL grain timings.
# GATE2   min signal level to register grain in File2: Range 0-1: default 1
# LEN     maximum time between grains
# GATE    min signal level to register grain in File1: Range 0-1: default 1
# MINHOLE min duration of inter-grain holes:
#         Min value (default) 0.032
# -t      Gate level tracks signal level,found with windowsize winsize(msecs)
#         Range(0.0 - infiledur): 0.0 turns off tracking)
# -x      ignore the last grain in the source.
# 
# Gate and Gate2 may vary over time.
# 
# 
cdp.grain.add_process("align", "sndfile", "sndfile", None, "Synchronise grain-onsets in 2 grainy-sound.")
params = []
cdp.grain.align.add_parameters(params)
#
# GRAIN ASSESS
#
# CDP Release 5 2005
# ASSESS BEST GATE VALUE TO FIND MAXIMUM NUMBER OF GRAINS IN FILE.
# USAGE:  grain assess infile
# 
# 
# 
cdp.grain.add_process("assess", "sndfile", "sndfile", None, "Estimate best gate value for grain extraction.")
params = []
cdp.grain.assess.add_parameters(params)
#
# GRAIN COUNT
#
# CDP Release 5 2005
# COUNT GRAINS FOUND IN A SOUND (AT GIVEN GATE & MINHOLE VALUES)
# 
# USAGE:
# grain count infile [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level, found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("count", "sndfile", "sndfile", None, "Count grains found in a grainy sound (at given gate & minhole).")
params = []
cdp.grain.count.add_parameters(params)
#
# GRAIN DUPLICATE
#
# CDP Release 5 2005
# DUPLICATE GRAINS IN GRAINY-SOUND
# 
# USAGE:
# grain duplicate infil outfil N [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# N        number of repetitions of each grain
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level, found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# N and Gate may vary over time.
# 
# 
cdp.grain.add_process("duplicate", "sndfile", "sndfile", None, "Duplicate grains in a grainy sound.")
params = []
cdp.grain.duplicate.add_parameters(params)
#
# GRAIN FIND
#
# CDP Release 5 2005
# LOCATE TIMINGS OF GRAIN-ONSETS IN A GRAINY-SOUND
# 
# USAGE:
# grain find infil out-textfil [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# OUT-TEXTFILE will contain a list of grain-onset timings, in seconds.
# LEN          maximum time between grains
# GATE         min signal level for grain to be seen: Range 0-1: default 1
# MINHOLE      min duration of inter-grain holes:
#              Min value (default) 0.032
# -t           Gate tracks signal level,found with windowsize winsize(msecs)
#              Range(0.0 - infiledur): 0.0 turns off tracking)
# -x           ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("find", "sndfile", "sndfile", None, "Locate timings of grain-onsets in a grainy sound.")
params = []
cdp.grain.find.add_parameters(params)
#
# GRAIN GREV
#
# CDP Release 5 2005
# FIND AND MANIPULATE 'GRAINS', USING ENVELOPE TROUGHS AND ZERO-CROSSINGS.
# This process locates elements of sound by searching for troughs in envelope.
# It doesn't need a clear attack to recognise 'grain' in sound, and is
# more appropriate for e.g. separating syllables in speech.
# 
# (REVERSE)     USAGE: grain grev 1 inf outf wsiz trof gpcnt
# (REPEAT)      USAGE: grain grev 2 inf outf wsiz trof gpcnt repets
# (DELETE)      USAGE: grain grev 3 inf outf wsiz trof gpcnt keep outof
# (OMIT)        USAGE: grain grev 4 inf outf wsiz trof gpcnt keep outof
# (TIMESTRETCH) USAGE: grain grev 5 inf outf wsiz trof gpcnt tstretch
# (GET)         USAGE: grain grev 6 inf out_timesfile wsiz trof gpcnt
# (PUT)         USAGE: grain grev 7 inf outf in_timesfile wsiz trof gpcnt
# WSIZ    sizeof window in ms, determines size of grains to find.
# TROF    acceptable trough height, relative to adjacent peaks (range >0 - <1)
# GPCNT   number of grains to treat as a unit in the operations.
# REPETS  number of repetitions of each unit.
# KEEP | OUTOF  number of units to keep, e.g. 3 out of 5.
# TSTRETCH amount to timestretch output (grains NOT streched) (Range .01 - 100).
# GET gets grain-pos to (text) timesfile: PUT puts grains at times in timesfile
# DELETE removes specified units: OMIT replaces them with silence,
# GPCNT, REPETS, KEEP and TSTRETCH can vary over time,
# 
# 
cdp.grain.add_process("grev", "sndfile", "sndfile", 7, "Find and manipulate ‘grains’, particularly vocal syllables.")
params = []
cdp.grain.grev.add_mode(1, params, "REVERSE")
params = []
cdp.grain.grev.add_mode(2, params, "REPEAT")
params = []
cdp.grain.grev.add_mode(3, params, "DELETE")
params = []
cdp.grain.grev.add_mode(4, params, "OMIT")
params = []
cdp.grain.grev.add_mode(5, params, "TIMESTRETCH")
params = []
cdp.grain.grev.add_mode(6, params, "GET (= Create Timesfile)")
params = []
cdp.grain.grev.add_mode(7, params, "PUT (= Use Timesfile)")
#
# GRAIN NOISE_EXTEND
#
# CDP Release 5 2005
# FIND AND TIME-STRETCH' NOISE COMPONENT IN SOUND.
# USAGE: 
# grain noise_extend inf outf duration minfrq mindur maxdur [-x]
# DURATION   Duration of noise (part of) output file.
# MINFRQ     lowest 'frequency' (Hz) acceptable as noise (try 6000.0)
# MINDUR     Minimum duration of signal (in ms) acceptable as noise source.
# MAXDUR     Maximum duration of signal (in secs) acceptable as noise source.
# -x         Keep only the extended noise: default keep rest of input src too.
# 
# 
cdp.grain.add_process("noise_extend", "sndfile", "sndfile", None, "Find and timestretch (first) noise component in a sound.")
params = []
cdp.grain.noise_extend.add_parameters(params)
#
# GRAIN OMIT
#
# CDP Release 5 2005
# OMIT A PROPORTION OF GRAINS FROM GRAINY-SOUND
# 
# USAGE:
# grain omit inf outf keep out-of [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# KEEP     number of grains to keep from each set of 'out_of' grains
# OUT_OF   'keep' grains retained from start of each set of 'out_of' grains
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level, found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# Keep may vary over time, but must not exceed 'out_of'.
# 
# 
cdp.grain.add_process("omit", "sndfile", "sndfile", None, "Omit a proportion of grains in a grainy sound.")
params = []
cdp.grain.omit.add_parameters(params)
#
# GRAIN REMOTIF
#
# CDP Release 5 2005
# CHANGE PITCH AND RHYTHM OF GRAINS IN GRAINY-SOUND
# 
# USAGE:
# grain remotif mode infile outfile transpmultfile
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# MODES are:-
# (1) Transform each grain in turn, without repeating any grains:
#     on reaching end of transpmultfile-data, cycle back to its start.
# (2) Transform grain in each specified way, before proceeding to next grain.
# 
# TRANSPMULTFILE is a file containing transposition\time-multiplier PAIRS.
#                Transpositions are (+ve or -ve) semitone shifts.
#                Max transposition is 4 octaves up or down.
#                Time-multipliers change the duration
#                between one grain onset and the next grain onset.
#                Max multiplier is 1000 : Min multiplier is 0.001000
#                if any inter-grain time reduced below MINGRAINTIME (0.032)
#                it will be set to MINGRAINTIME.
# 
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level,found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("remotif", "sndfile", "sndfile", 2, "Change pitch and rhythm of grains in a grainy sound.")
params = []
cdp.grain.remotif.add_mode(1, params, "NO GRAIN REPEATS")
params = []
cdp.grain.remotif.add_mode(2, params, "REPEAT EACH GRAIN")
#
# GRAIN REORDER
#
# CDP Release 5 2005
# REORDER GRAINS IN GRAINY-SOUND
# 
# USAGE:
# grain reorder infil outfil code [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# CODE     a string such as 'adb:c' indicating how grains are to be reordered.
#          The example means use grains 1 (a), 4 (d) and 2 (b) in sequence,
#          then begin this grain-jumping pattern again, BUT start at grain3 (c).
#          Continue to advance in this fashion until no grains left in infile.
#          The ':' is obligatory.
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level, found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("reorder", "sndfile", "sndfile", None, "Reorder grains in a grainy sound.")
params = []
cdp.grain.reorder.add_parameters(params)
#
# GRAIN REPITCH
#
# CDP Release 5 2005
# REPITCH GRAINS IN GRAINY-SOUND
# 
# USAGE:
# grain repitch mode infile outfile transpfile
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# MODES are:-
# (1)   Repitch each grain in turn, without repeating any grains:
#       on reaching end of transposition list, cycle back to its start.
# (2)   Play grain at each transposed pitch, before proceeding to next grain.
# 
# TRANSPFILE is a file listing transpositions as (+ve or -ve) semitone shifts.
#            Max transposition is 4 octaves up or down
# 
# LEN        maximum time between grains
# GATE       required signal level for grain to be seen: Range 0-1:default 1
# MINHOLE    min duration of inter-grain holes:
#            Min value (default) 0.032
# -t         Gate level tracks signal level,found with windowsize winsize(msecs)
#            Range(0.0 - infiledur): 0.0 turns off tracking)
# -x         ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("repitch", "sndfile", "sndfile", 2, "Repitch grains in a grainy sound.")
params = []
cdp.grain.repitch.add_mode(1, params, "NO GRAIN REPEATS")
params = []
cdp.grain.repitch.add_mode(2, params, "REPEAT EACH GRAIN")
#
# GRAIN REPOSITION
#
# CDP Release 5 2005
# REPOSITION GRAIN-ONSETS IN A GRAINY-SOUND
# 
# USAGE:
# grain reposition infile outfile timefile offset
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# TIMEFILE  must contain a list of grain-onset timings, in seconds.
#           if any inter-grain time reduced below MINGRAINTIME (0.032)
#           it will be set to MINGRAINTIME.
# OFFSET    add this value (secs) to ALL grain timings.
# LEN       maximum time between grains
# GATE      min signal level for grain to be seen: Range 0-1: default 1
# MINHOLE   min duration of inter-grain holes:
#           Min value (default) 0.032
# -t        Gate level tracks signal level,found with windowsize winsize(msecs)
#           Range(0.0 - infiledur): 0.0 turns off tracking)
# -x        ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("reposition", "sndfile", "sndfile", None, "Reposition grain-onset in a grainy sound.")
params = []
cdp.grain.reposition.add_parameters(params)
#
# GRAIN RERHYTHM
#
# CDP Release 5 2005
# CHANGE RHYTHM OF GRAINS IN GRAINY-SOUND
# 
# USAGE:
# grain rerhythm mode infile outfile multfile
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# MODES are:-
# (1) Lengthen or shorten each grain in turn, without repeating any grains:
#     on reaching end of time-multipliers list, cycle back to its start.
# (2) Play grain at each specified retiming, before proceeding to next grain.
# 
# MULTFILE is a file listing duration-multipliers to change the duration
#          between one grain onset and the next grain onset.
#          Max multiplier is 1000 : Min multiplier is 0.001000
#          if any inter-grain time reduced below MINGRAINTIME (0.032)
#          it will be set to MINGRAINTIME.
# 
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level,found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("rerhythm", "sndfile", "sndfile", 2, "Change rhythm of grains in a grainy sound.")
params = []
cdp.grain.rerhythm.add_mode(1, params, "NO GRAIN REPEATS")
params = []
cdp.grain.rerhythm.add_mode(2, params, "REPEAT EACH GRAIN")
#
# GRAIN REVERSE
#
# CDP Release 5 2005
# REVERSE ORDER OF GRAINS IN A GRAINY-SOUND
#    WITHOUT REVERSING GRAINS THEMSELVES
# 
# USAGE:
# grain reverse infil outfil [-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level,found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Gate may vary over time.
# 
# 
cdp.grain.add_process("reverse", "sndfile", "sndfile", None, "Reverse order of grains in sound, but NOT grains themselves.")
params = [
        ["-b", 0, None, "maximum time between grains"],
        ["-l", 0, 1, "required signal level for grain to be seen"],
        ["-h", 0.032, None, "min duration of inter-grain-holes"],
        ["-t", 0.0, None, "Gate level tracks signal level, found with windowsize winsize(msecs)\nRange(0.0 - infiledur): 0.0 turns off tracking"],
        ["-x", 0, 1, "ignore the last grain in the source"]
        ]
cdp.grain.reverse.add_parameters(params)
#
# GRAIN R_EXTEND
#
# CDP Release 5 2005
# TIME-STRETCH' NATURAL ITERATIVE SOUNDS LIKE THE ROLLED 'rrr' IN SPEECH.
# IN MODE 1 you mark where iterative part of sound is.
# grain r_extend mode inf outf stt end ts pr rep get asc psc [-x]
#      STT      Time of start of iterated material within source.
#      END      Time of end of iterated material within source.
# IN MODE 2 process attempts to find it, using envelope tracing.
# grain r_extend mode inf outf gate usz ts pr rep get asc psc skp at T by [-s] [-e]
#      GATE     min level in src for env tracing to kick in (0-1).
#      USZ      size of unit searched for, in ms (15 for rolled rr).
#      SKP      number of found units to skip before processing.
#      at   T   iterative rits, after 'at' secs, to event-separation 'T'
#      by       reached after further 'by' secs: 'by'=ZERO gives NO RIT
# TS       How much to time-stretch the marked (or found) material.
# PR       Guesstimate pitch-range of iteration in src - in octaves (try 1).
# REP      Iterated material extended by reusing individual segments
#          'repets' is no. of adjacent copies of any seg you allow (try 1-2)
# GET      Guesstimate no. of iterations expected (listen to snd).
#          In MODE 2 this is the MINIMUM no of repeats you expect to find.
# ASC      Ouput segs made to vary randomly in amplitude. (Range 0-1)
#          Value multiplies orig seg amp by rand val in range 1 to (1-N).
# PSC      Output segs made to vary randomly in pitch (Range 0-24)
#          Val transposes pitch by randval in range -N to +N semitones.
# -x  keep rrr-extension only   -s keep snd before   -e Keep snd after.
# 
# 
cdp.grain.add_process("r_extend", "sndfile", "sndfile", None, "Extend sounds that are iterative.")
params = []
cdp.grain.r_extend.add_parameters(params)
#
# GRAIN TIMEWARP
#
# CDP Release 5 2005
# STRETCH (OR SHRINK) DURATION OF GRAINY-SOUND
#     WITHOUT STRETCHING GRAINS THEMSELVES
# 
# USAGE:
# grain timewarp infile outfile timestretch-ratio
# 		[-blen] [-lgate] [-hminhole] [-twinsize] [-x]
# 
# TIMESTRETCH-RATIO is degree of stretching/shrinking of intergrain time.
#                   a value of 2 doubles the intergrain time.
#                   a value of .5 halves the intergrain time.
#                   Max stretch is 1000 : Min shrink is 0.001000
#                   if any inter-grain time reduced below MINGRAINTIME (0.032)
#                   it will be set to MINGRAINTIME.
# 
# LEN      maximum time between grains
# GATE     required signal level for grain to be seen: Range 0-1: default 1
# MINHOLE  min duration of inter-grain holes:
#          Min value (default) 0.032
# -t       Gate level tracks signal level,found with windowsize winsize(msecs)
#          Range(0.0 - infiledur): 0.0 turns off tracking)
# -x       ignore the last grain in the source.
# 
# Timestretch-ratio and Gate may vary over time.
# Times in brkpnt files refer to INFILE time.
# 
# 
cdp.grain.add_process("timewarp", "sndfile", "sndfile", None, "Stretch (or shrink) duration of sound, but NOT of grains.")
params = []
cdp.grain.timewarp.add_parameters(params)
#
# STRANGE
#
#
# STRANGE GLISS
#
# CDP Release 5 2005
# Unknown option 'gliss'
# 
# 
cdp.strange.add_process("gliss", "analfile", "analfile", 3, "Create glissandi inside (changing) spectral envelope sound.")
params = []
cdp.strange.gliss.add_mode(1, params, "SHEPARD TONE GLIS")
params = []
cdp.strange.gliss.add_mode(2, params, "INHARMONIC GLIS")
params = []
cdp.strange.gliss.add_mode(3, params, "SELF GLIS")
#
# STRANGE INVERT
#
# CDP Release 5 2005
# strange invert mode infile outfile
# 
# INVERT THE SPECTRUM
# 
# MODES :-
# 1	Normal inversion.
# 2	Output sound retains amplitude envelope of source sound.
# 
# 
cdp.strange.add_process("invert", "analfile", "analfile", 2, "Invert spectrum.")
params = []
cdp.strange.invert.add_mode(1, params, "STANDARD")
params = []
cdp.strange.invert.add_mode(2, params, "RETAIN SOURCE ENVELOPE")
#
# STRANGE SHIFT
#
# CDP Release 5 2005
# strange shift 1   infile outfile frqshift               [-l]
# strange shift 2-3 infile outfile frqshift frq_divide    [-l]
# strange shift 4-5 infile outfile frqshift frqlo   frqhi [-l]
# 
# LINEAR FREQUENCY SHIFT OF (PART OF) THE SPECTRUM
# 
# MODES :-
# 1   Shift the whole spectrum.
# 2   Shift the spectrum above frq_divide.
# 3   Shift the spectrum below frq_divide.
# 4   Shift the spectrum only in the range frqlo and frqhi.
# 5   Shift the spectrum outside the range  frqlo to frqhi.
# 
# frqshift      linear shift of spectral frequencies (same for all).
# frq_divide    frq at which shifting starts or stops.
# frqlo & frqhi define a range inside or outside of which shifting takes place.
# -l            log interpolation between varying frq vals (Default: linear).
#               (Useful only if any of above input parameters are time-varying,
#                AND frqshift vals must be all +ve, or all -ve for this to work).
# 
# frqshift,frq_divide,frqlo & frqhi may vary over time.
# 
# 
cdp.strange.add_process("shift", "analfile", "analfile", 5, "Linear (inharmonic) frequency shift of (part of) the spectrum.")
params = []
cdp.strange.shift.add_mode(1, params, "SHIFT ALL")
params = []
cdp.strange.shift.add_mode(2, params, "SHIFT ABOVE FRQ")
params = []
cdp.strange.shift.add_mode(3, params, "SHIFT BELOW FRQ")
params = []
cdp.strange.shift.add_mode(4, params, "SHIFT BETWEEN FRQS")
params = []
cdp.strange.shift.add_mode(5, params, "SHIFT OUTSIDE FRQS")
#
# STRANGE WAVER
#
# CDP Release 5 2005
# strange waver 1 infile outfile vibfrq stretch botfrq
# strange waver 2 infile outfile vibfrq stretch botfrq expon
# 
# OSCILLATE BETWEEN HARMONIC AND INHARMONIC STATE
# 
# MODES :-
# 1   Standard spectral stretching for inharmonic state.
# 2   Specify spectral stretching for inharmonic state.
# 
# vibfrq    is frq of oscillation. 
# stretch   is maximum spectral stretch in inharmonic state. 
# botfrq    is frq above which spectral stretching happens.
# expon     defines type of stretch (must be > 0.0).
# 
# vibfrq and stretch may vary over time.
# 
# 
cdp.strange.add_process("waver", "analfile", "analfile", 2, "Oscillate between harmonic and inharmonic state.")
params = [
        ["vibfrq", 0, 22050, "frq of oscillation"],
        ["stretch", 0, None, "maximum spectral stretch in inharmonic state"],
        ["botfreq", 0, None, "frq above which spectral stretching happens"]
        ]
cdp.strange.waver.add_mode(1, params, "STANDARD")
params.append([
        ["expon", 0.00001, None, "defines type of stretch (must be > 0.0"]
        ])
cdp.strange.waver.add_mode(2, params, "USER SPECIFIED")
#
# ENVEL
#
#
# ENVEL ATTACK
#
# CDP Release 5 2005
# EMPHASIZE THE ATTACK OF A SOUND
# 
# envel attack 1 infile outfile gate gain onset decay [-tenvtype]
# envel attack 2 infile outfile time gain onset decay [-tenvtype]
# envel attack 3 infile outfile time gain onset decay [-tenvtype]
# envel attack 4 infile outfile      gain onset decay [-tenvtype]
# 
# MODES ARE:
# 1) Set attack point where snd level first exceeds gate-level.
# 2) attack point at max level around your approx-time (+- 200 MS)
# 3) attack point at your exact-time.
# 4) attack point at maxlevel in sndfile.
# 
# GAIN:    Amplification of attack point
# GATE:    Level for attack point to be recognised: Range(0 - 1)
# TIME:    Time (approx or exact) of attack point,in secs.
# ONSET:   Attack onset duration (MS): Range(5 to 32767)
# DECAY:   Attack decay duration (MS): Range(5 to <infiledur)
# ENVTYPE: 0 linear: 1 exponential(default).
# 
# 
cdp.envel.add_process("attack", "sndfile", "sndfile", 4, "Emphasise the attack of a sound.")
params = []
cdp.envel.attack.add_mode(1, params, "WHERE GATE EXCEEDED")
params = []
cdp.envel.attack.add_mode(2, params, "NEAR TIME GIVEN")
params = []
cdp.envel.attack.add_mode(3, params, "AT EXACT TIME GIVEN")
params = []
cdp.envel.attack.add_mode(4, params, "AT MAX LEVEL IN FILE")
#
# ENVEL BRKTOENV
#
# CDP Release 5 2005
# CONVERT A (TEXT) BRKPNT ENVELOPE TO A BINARY ENVELOPE FILE.
# 
# USAGE: envel brktoenv inbrkfile outenvfile  wsize
# 
# WSIZE      window_size (in MS) for scanning envelope: Range (5 - filelen)
# 
# If brkpnt starttime > zero, new envelope will start from zero,
# holding the brktabel startval as far as first brktable time.
# 
# 
cdp.envel.add_process("brktoenv", "brkfile", "brkfile", None, "Convert (text) breakpoint envelope to binary envelope file.")
params = []
cdp.envel.brktoenv.add_parameters(params)
#
# ENVEL CREATE
#
# CDP Release 5 2005
# CREATE AN ENVELOPE.
# 
# USAGE: envel create 1 envfile createfile  wsize
# OR:    envel create 2 brkfile createfile
# 
# MODES..
# 1) creates a BINARY envelope file:
#    If you specify starttime > 0,vals from 0 to starttime hold your startlevel.
# 2) creates a (TEXT) BRKPNT file:   File starts at time you specify.
# 
# WSIZE      window_size (in MS) of envelope to be created.
#            Range (5 - filelen)
# CREATEFILE is a textfile with the following format:
#            time [e]level time [e]level ......
# where time-level pairs can be repeated as often as desired.
# Level is a number between 0 and 1, or a dB value between -96dB and 0dB
# (you must write 'dB' if you want dB).
# If preceded by an 'e', envelope rises[falls] exponentially to that level.
# Default is linear rise[fall].
# 
# Times are in seconds, must increase through the file,
# and be separated by at least 0.010 secs
# 
# 
cdp.envel.add_process("create", "textfile", "textfile", 2, "Create an envelope.")
params = []
cdp.envel.create.add_mode(1, params, "BINARY OUTPUT")
params = []
cdp.envel.create.add_mode(2, params, "TEXTFILE OUTPUT")
#
# ENVEL CURTAIL
#
# CDP Release 5 2005
# CURTAIL SNDFILE BY FADING TO ZERO AT SOME TIME WITHIN IT.
# 
# USAGE: envel curtail 1 sndfile outfile fadestart fadeend  envtype [-ttimes]
# OR:    envel curtail 2 sndfile outfile fadestart fade-dur envtype [-ttimes]
# OR:    envel curtail 3 sndfile outfile fadestart          envtype [-ttimes]
# 
# OR:    envel curtail 4 sndfile outfile fadestart fadeend          [-ttimes]
# OR:    envel curtail 5 sndfile outfile fadestart fade-dur         [-ttimes]
# OR:    envel curtail 6 sndfile outfile fadestart                  [-ttimes]
# 
# MODES 4-6 produce doubly exponential (steeper) editing slope.
# 
# FADESTART is start-time of fade.
# FADEEND   is end-time of fade. (In MODE 3, assumed to be endtime of origsnd).
# FADE-DUR  is duration of fade-out.
# ENVTYPE   0 for linear fade, 1 (default) for exponential fade.
# -t        TIMES for fade start, end or duration are given in the units....
#           seconds (-t0) samples (-t1), or grouped-samples (-t2)
# 
# 
cdp.envel.add_process("curtail", "sndfile", "sndfile", 3, "Curtail soundfile by fading to zero at some time within it.")
params = []
cdp.envel.curtail.add_mode(1, params, "GIVE START & END OF FADE")
params = []
cdp.envel.curtail.add_mode(2, params, "GIVE START & DUR OF FADE")
params = []
cdp.envel.curtail.add_mode(3, params, "GIVE START OF FADE-TO-END")
#
# ENVEL CYCLIC
#
# CDP Release 5 2005
# CREATE A SEQUENCE OF REPEATED ENVELOPES, IN A BINARY ENVELOPE FILE.
# 
# USAGE: envel cyclic 1-3 outf       wsize total-dur cell-dur phase trough env-exp
# OR:    envel cyclic 4 outf userenv wsize total-dur cell-dur phase
# 
# MODES:
# (1) Rising. (2) Falling. (3) Troughed (falls then rises)  (4) User-defined
# 
# WSIZE       Envelope window size (ms) : Resolution of envelope generated.
# TOTAL-DUR   Duration of output file.
# CELL-DUR    Duration of individual (repeated) units: can vary over time.
# PHASE       Where in cell-envelope to begin output: 0=start, 1=end of cell.
# TROUGH      Lowest point of envelope cell (Range 0 -1): can vary over time.
# ENV-EXP     Shape of env: 1 linear: <1 steep at top, > 1 steep at bottom.
# 
# USERENV     textfile of time/val(0-1) pairs defining env (time units arbitrary)
#             as the envelope is stretched to each unit duration.
# 
# 
cdp.envel.add_process("cyclic", "sndfile", "sndfile", 4, "Create a sequence of repeated envelopes, in a binary envelope file.")
params = []
cdp.envel.cyclic.add_mode(1, params, "RISING")
params = []
cdp.envel.cyclic.add_mode(2, params, "FALLING")
params = []
cdp.envel.cyclic.add_mode(3, params, "TROUGHED (FALLS THEN RISES)")
params = []
cdp.envel.cyclic.add_mode(4, params, "USER-DEFINED")
#
# ENVEL DBTOENV
#
# CDP Release 5 2005
# CONVERT A (TEXT) BRKPNT FILE WITH VALS IN dB TO AN ENVELOPE FILE
# 
# envel dbtoenv db_brkfile outenvfile  wsize
# 
# WSIZE is duration of enveloping window, in MS.
# 
# 
cdp.envel.add_process("dbtoenv", "db_brkfile", "db_brkfile", None, "Convert (text) breakpoint file with dB values to binary file.")
params = []
cdp.envel.dbtoenv.add_parameters(params)
#
# ENVEL DBTOGAIN
#
# CDP Release 5 2005
# CONVERT A (TEXT) BRKPNT FILE WITH dB VALS TO GAIN VALS
# 
# envel dbtogain db_brkfile outbrkfile
# 
# 
cdp.envel.add_process("dbtogain", "db_brkfile", "db_brkfile", None, "Convert (text) breakpoint file with dB values to gain values (0-1).")
params = []
cdp.envel.dbtogain.add_parameters(params)
#
# ENVEL DOVETAIL
#
# CDP Release 5 2005
# DOVETAIL SNDFILE BY ENVELOPING THE START AND END OF IT.
# 
# USAGE:
# envel dovetail 1 infile outfile infadedur outfadedur intype outtype [-ttimes]
# OR:   
# envel dovetail 2 infile outfile infadedur outfadedur [-ttimes]
# 
# In mode 2, the dovetail slopes are doubly exponential (steeper).
# 
# INFADE-DUR  is duration of start-of-file fade-in.
# OUTFADE-DUR is duration of end-of-file fade-out.
#             Infade-dur and Outfade-dur must not overlap each another.
# INTYPE      0 for linear fade, 1 (default) for exponential fade, at start.
# OUTTYPE     0 for linear fade, 1 (default) for exponential fade, at end.
# -t          times for fade durations are given in the units....
#             seconds (-t0) samples (-t1), or grouped-samples (-t2)
# 
# 
# TODO: COME BACK
"""
cdp.envel.add_process("dovetail", "sndfile", "sndfile", 2, "Dovetail soundfile by enveloping start and end of it.")
params = []
cdp.envel.dovetail.add_mode(1, params, "NORMAL FADES, LIN OR EXP")
params = []
cdp.envel.dovetail.add_mode(2, params, "DOUBLY-EXPONENTIAL FADES")
"""
#
# ENVEL ENVTOBRK
#
# CDP Release 5 2005
# CONVERT A BINARY ENVELOPE FILE TO A (TEXT) BRKPNT ENVELOPE.
# 
# USAGE: envel envtobrk inenvfile outbrkfile  [-ddatareduce]
# 
# DATAREDUCE variable determines quantity v. accuracy of data written to brkfile.
#            Range(0 - 1)
# 
# 
cdp.envel.add_process("envtobrk", "envfile", "envfile", None, "Convert binary envelope file to a (text) breakpoint file.")
params = []
cdp.envel.envtobrk.add_parameters(params)
#
# ENVEL ENVTODB
#
# CDP Release 5 2005
# CONVERT A BINARY ENVELOPE FILE TO A (TEXT) BRKPNT ENVELOPE WITH dB VALUES.
# 
# USAGE: envel envtodb inenvfile outbrkfile  [-ddatareduce]
# 
# DATAREDUCE variable determines quantity v. accuracy of data written to brkfile.
#            Range(0 - 1)
# 
# 
cdp.envel.add_process("envtodb", "envfile", "envfile", None, "Convert binary envelope file to (text) breakpoint file with dB values.")
params = []
cdp.envel.envtodb.add_parameters(params)
#
# ENVEL EXTRACT
#
# CDP Release 5 2005
# EXTRACT ENVELOPE FROM AN INPUT SOUNDFILE.
# 
# USAGE: envel extract  1  infile outenvfile  wsize
# OR:    envel extract  2  infile outbrkfile  wsize  [-ddatareduce]
# 
# MODE 1 extracts a binary envelope file:
# MODE 2 extracts a (text) brkpnt file.
# 
# WSIZE      window_size (in MS) for scanning envelope: Range (5 - filelen)
# DATAREDUCE variable determines quantity v. accuracy of data written to brkfile
#            Range(0 - 1)
# 
# 
cdp.envel.add_process("extract", "sndfile", "sndfile", 2, "Extract envelope from an input soundfile.")
params = []
cdp.envel.extract.add_mode(1, params, "BINARY OUTPUT")
params = []
cdp.envel.extract.add_mode(2, params, "TEXTFILE OUTPUT")
#
# ENVEL GAINTODB
#
# CDP Release 5 2005
# CONVERT A (TEXT) BRKPNT FILE WITH GAIN VALS TO dB VALS
# 
# envel gaintodb brkfile out_db_brkfile
# 
# 
cdp.envel.add_process("gaintodb", "brkfile", "brkfile", None, "Convert (text) breakpoint file with gain (0-1) values to dB values.")
params = []
cdp.envel.gaintodb.add_parameters(params)
#
# ENVEL IMPOSE
#
# CDP Release 5 2005
# IMPOSE AN ENVELOPE ON AN INPUT SOUNDFILE.
# 
# USAGE: envel impose  1  input_sndfile imposed-sndfile    outsndfile    wsize
# USAGE: envel impose  2  input_sndfile imposed-envfile    outsndfile
# USAGE: envel impose  3  input_sndfile imposed-brkfile    outsndfile
# USAGE: envel impose  4  input_sndfile imposed-brkfile-dB outsndfile
# 
# MODE 1 imposes an envelope extracted from another sndfile.
# MODE 2 imposes an envelope from a binary envelope file.
# MODE 3 imposes an envelope from a (text) brkpnt file: val range (0 - 1).
# MODE 4 imposes an envelope from a (text) brkpnt file with dB vals (-96 to 0).
# 
# WSIZE      window_size (in MS) for scanning envelope: Range (5 - filelen)
# 
# In MODES 1 & 2, the whole sndfile is enveloped.
# In MODES 3 & 4, brkpnt may start (and end) at any time in file,
#                 effectively editing it. Must have at least 2 brkpnt pairs.
# 
# 
cdp.envel.add_process("impose", "sndfile", "sndfile", 4, "Impose an envelope on an input soundfile.")
params = []
cdp.envel.impose.add_mode(1, params, "ENV FROM OTHER SNDFILE")
params = []
cdp.envel.impose.add_mode(2, params, "ENV IN BINARY FILE")
params = []
cdp.envel.impose.add_mode(3, params, "ENV IN TEXTFILE")
params = []
cdp.envel.impose.add_mode(4, params, "ENV IN dB TEXTFILE")
#
# ENVEL PLUCK
#
# CDP Release 5 2005
# PLUCK START OF SOUND (MONO FILES ONLY)
# 
# envel pluck infile outfile startsamp wavelen [-aatkcycles] [-ddecayrate]
# 
# STARTSAMP  Sample, in src sound, at which pluck will END:
#            must be a sample AT A ZERO_CROSSING...
# WAVELEN    no of (absolute) samples in pluck wavelen: 
#            should be same as src_signal's wavelen immediately after STARTSAMP
# ATKCYCLES  no of wavecycles in pluck-attack : Range(2 - 32767) (Default 32)
# DECAYRATE  rate of decay of the pluck_attack: Range(1 - 64) (Default 48)
# 
# 
cdp.envel.add_process("pluck", "sndfile", "sndfile", None, "Create pluck on start of sound (MONO files only).")
params = []
cdp.envel.pluck.add_parameters(params)
#
# ENVEL REPLACE
#
# CDP Release 5 2005
# REPLACE THE EXISTING ENVELOPE OF AN INPUT SOUNDFILE
#             WITH A DIFFERENT ENVELOPE.
# 
# USAGE: envel replace 1 input_sndfile replacing-sndfile    outsndfile wsize
# USAGE: envel replace 2 input_sndfile replacing-envfile    outsndfile
# USAGE: envel replace 3 input_sndfile replacing-brkfile    outsndfile wsize
# USAGE: envel replace 4 input_sndfile replacing-brkfile-dB outsndfile wsize
# 
# MODES:
# 1 replaces envelope with new one extracted from another sndfile.
# 2 replaces envelope with new one from a binary envelope file.
# 3 replaces envelope with new one from (text) brkpnt file: valrange 0-1.
# 4 replaces envelope with new one from (text) brkpnt file in dB (-96 to 0).
# 
# In all cases, the entire sndfile is enveloped
# 
# WSIZE      window_size (in MS) for scanning envelope: Range (5 - filelen)
# 
# MODE 1 is especially useful for restoring the amplitude contour of a sound
# after filtering with time-varying Q-value.
# 
# 
cdp.envel.add_process("replace", "sndfile", "sndfile", 4, "Replace existing envelope of an input soundfile.")
params = []
cdp.envel.replace.add_mode(1, params, "ENV FROM OTHER SNDFILE")
params = []
cdp.envel.replace.add_mode(2, params, "ENV IN BINARY FILE")
params = []
cdp.envel.replace.add_mode(3, params, "ENV IN TEXTFILE")
params = []
cdp.envel.replace.add_mode(4, params, "ENV IN dB TEXTFILE")
#
# ENVEL REPLOT
#
# CDP Release 5 2005
# WARP THE ENVELOPE IN A (TEXT) BRKPNT ENVELOPE FILE
# 
# envel replot 1-12  brkfile outbrkfile          wsize various_params [-dreduce]
# envel replot 13    brkfile outbrkfile rampfile wsize various_params [-dreduce]
# envel replot 14-15 brkfile outbrkfile          wsize various_params [-dreduce]
# 
# where MODE NUMBERS stand for are....
# 1 NORMALISE       5 LIFT            9  INVERT       13 TRIGGER
# 2 REVERSE         6 TIMESTRETCH     10 LIMIT        14 CEILING
# 3 EXAGGERATE      7 FLATTEN         11 CORRUGATE    15 DUCKED
# 4 ATTENUATE       8 GATE            12 EXPAND 
# 
# WSIZE   is duration of enveloping window, in MS.
# REDUCE  forces interpolation of data in brkpnt outfile
#         to reduce unnecessary data output: Range(0-1).
# 
# for more info on MODES, and their 'various_params', type e.g.:
#       'envel replot normalise' for more info on 'normalise' option... etc
# NB: TRIGGER works better using reshape or warp.
# 
# 
cdp.envel.add_process("replot", "brkfile", "brkfile", 15, "Warp envelope in a text breakpoint file.")
params = []
cdp.envel.replot.add_mode(1, params, "NORMALISE")
params = []
cdp.envel.replot.add_mode(2, params, "TIME REVERSE")
params = []
cdp.envel.replot.add_mode(3, params, "EXAGGERATE")
params = []
cdp.envel.replot.add_mode(4, params, "ATTENUATE")
params = []
cdp.envel.replot.add_mode(5, params, "LIFT ALL")
params = []
cdp.envel.replot.add_mode(6, params, "TIME-STRETCH")
params = []
cdp.envel.replot.add_mode(7, params, "FLATTEN")
params = []
cdp.envel.replot.add_mode(8, params, "GATE")
params = []
cdp.envel.replot.add_mode(9, params, "INVERT")
params = []
cdp.envel.replot.add_mode(10, params, "LIMIT")
params = []
cdp.envel.replot.add_mode(11, params, "CORRUGATE")
params = []
cdp.envel.replot.add_mode(12, params, "EXPAND")
params = []
cdp.envel.replot.add_mode(13, params, "TRIGGER BURSTS")
params = []
cdp.envel.replot.add_mode(14, params, "TO CEILING")
params = []
cdp.envel.replot.add_mode(15, params, "DUCKED")
#
# ENVEL RESHAPE
#
# CDP Release 5 2005
# WARP THE ENVELOPE IN A BINARY ENVELOPE FILE
# 
# envel reshape 1-12  envfile outenvfile          various_params
# envel reshape 13    envfile outenvfile rampfile various_params
# envel reshape 14-15 envfile outenvfile          various_params
# 
# where MODE NUMBERS stand for are....
# 1 NORMALISE       5 LIFT            9  INVERT       13 TRIGGER
# 2 REVERSE         6 TIMESTRETCH     10 LIMIT        14 CEILING
# 3 EXAGGERATE      7 FLATTEN         11 CORRUGATE    15 DUCKED
# 4 ATTENUATE       8 GATE            12 EXPAND 
# 
# for more info on MODES, and their 'various_params', type e.g.:
#       'envel reshape normalise' for more info on 'normalise' option... etc
# 
# 
cdp.envel.add_process("reshape", "envfile", "envfile", 15, "Warp envelope in a binary envelope file.")
params = []
cdp.envel.reshape.add_mode(1, params, "NORMALISE")
params = []
cdp.envel.reshape.add_mode(2, params, "TIME REVERSE")
params = []
cdp.envel.reshape.add_mode(3, params, "EXAGGERATE")
params = []
cdp.envel.reshape.add_mode(4, params, "ATTENUATE")
params = []
cdp.envel.reshape.add_mode(5, params, "LIFT ALL")
params = []
cdp.envel.reshape.add_mode(6, params, "TIME-STRETCH")
params = []
cdp.envel.reshape.add_mode(7, params, "FLATTEN")
params = []
cdp.envel.reshape.add_mode(8, params, "GATE")
params = []
cdp.envel.reshape.add_mode(9, params, "INVERT")
params = []
cdp.envel.reshape.add_mode(10, params, "LIMIT")
params = []
cdp.envel.reshape.add_mode(11, params, "CORRUGATE")
params = []
cdp.envel.reshape.add_mode(12, params, "EXPAND")
params = []
cdp.envel.reshape.add_mode(13, params, "TRIGGER BURSTS")
params = []
cdp.envel.reshape.add_mode(14, params, "TO CEILING")
params = []
cdp.envel.reshape.add_mode(15, params, "DUCKED")
#
# ENVEL SCALED
#
# CDP Release 5 2005
# IMPOSE AN ENVELOPE ON AN INPUT SOUNDFILE, SCALING IT TIMEWISE TO SOUND'S DURATION.
# 
# USAGE: envel  scaled  input_sndfile  imposed-brkfile  outsndfile
# 
# Must have at least 2 brkpnt pairs.
# 
# 
cdp.envel.add_process("scaled", "sndfile", "sndfile", None, "Impose envelope, scaling envelope times to soundfile duration.")
params = []
cdp.envel.scaled.add_parameters(params)
#
# ENVEL SWELL
#
# CDP Release 5 2005
# CAUSE SOUND TO FADE IN TO AND OUT FROM A PEAK MOMENT
# 
# envel swell infile outfile peaktime peaktype
# 
# PEAKTYPE: 0 linear: 1 (default) exponential
# 
# 
cdp.envel.add_process("swell", "sndfile", "sndfile", None, "Cause sound to fade in to and out from a peak moment.")
params = []
cdp.envel.swell.add_parameters(params)
#
# ENVEL TIMEGRID
#
# CDP Release 5 2005
# PARTITION SOUNDFILE INTO STAGGERED GRIDS.
# EACH GRID IS SEQUENCE OF WINDOWS FROM SOURCE, AT THEIR ORIGINAL TIMES, SEPARATED BY SILENCE.
# 
# USAGE: envel timegrid input_sndfile  generic_outsndfile_name gridcnt gridwidth splicelen
# 
# GRIDCNT      Number of grids (and hence output files).
# GRIDWIDTH    Duration of Grid windows, in seconds.
# SPLICELEN    Splice length, in mS
# 
# gridwidth and splicelen may vary over time.
# 
# 
cdp.envel.add_process("timegrid", "sndfile", "sndfile", None, "Partition a soundfile into a sequence of ‘windows’ separated by silence.")
params = []
cdp.envel.timegrid.add_parameters(params)
#
# ENVEL TREMOLO
#
# CDP Release 5 2005
# TREMOLO A SOUND
# 
# USAGE: envel tremolo mode infile outfile frq depth gain
# 
# MODES:
# 1) Interpolate linearly between frqs in any frq brktable (default).
# 2) Interpolate logarithmically (like pitch). (Care with zero frqs).
# 
# FRQ          frequency of tremolo (0 - 500) 
# DEPTH        depth of tremolo: Range(0 to 1: default 0.250)
# GAIN         Overall signal gain, or envelope: Range(0 to 1: default 1)
# 
# Frq, Depth and Gain may vary over time.
# 
# 
cdp.envel.add_process("tremolo", "sndfile", "sndfile", 2, "Tremolo a sound.")
params = []
cdp.envel.tremolo.add_mode(1, params, "FRQWISE")
params = []
cdp.envel.tremolo.add_mode(2, params, "PITCHWISE")
#
# ENVEL WARP
#
# CDP Release 5 2005
# WARP THE ENVELOPE OF AN SOUNDFILE
# 
# envel warp 1-12  sndfile outsndfile          wsize various_params
# envel warp 13    sndfile outsndfile rampfile wsize various_params
# envel warp 14-15 sndfile outsndfile          wsize various_params
# 
# where MODE NUMBERS stand for are....
# 1 NORMALISE       5 LIFT            9  INVERT       13 TRIGGER
# 2 REVERSE         6 TIMESTRETCH     10 LIMIT        14 CEILING
# 3 EXAGGERATE      7 FLATTEN         11 CORRUGATE    15 DUCKED
# 4 ATTENUATE       8 GATE            12 EXPAND 
# 
# WSIZE is duration of enveloping window, in MS.
# 
# for more info on MODES, and their 'various_params', type e.g.:
#       'envel warp normalise' for more info on 'normalise' option... etc
# 
# 
cdp.envel.add_process("warp", "sndfile", "sndfile", 15, "Warp envelope of a soundfile.")
params = []
cdp.envel.warp.add_mode(1, params, "NORMALISE")
params = []
cdp.envel.warp.add_mode(2, params, "TIME REVERSE")
params = []
cdp.envel.warp.add_mode(3, params, "EXAGGERATE")
params = []
cdp.envel.warp.add_mode(4, params, "ATTENUATE")
params = []
cdp.envel.warp.add_mode(5, params, "LIFT ALL")
params = []
cdp.envel.warp.add_mode(6, params, "TIME-STRETCH")
params = []
cdp.envel.warp.add_mode(7, params, "FLATTEN")
params = []
cdp.envel.warp.add_mode(8, params, "GATE")
params = []
cdp.envel.warp.add_mode(9, params, "INVERT")
params = []
cdp.envel.warp.add_mode(10, params, "LIMIT")
params = []
cdp.envel.warp.add_mode(11, params, "CORRUGATE")
params = []
cdp.envel.warp.add_mode(12, params, "EXPAND")
params = []
cdp.envel.warp.add_mode(13, params, "TRIGGER BURSTS")
params = []
cdp.envel.warp.add_mode(14, params, "TO CEILING")
params = []
cdp.envel.warp.add_mode(15, params, "DUCKED")
#
# HOUSEKEEP
#
#
# HOUSEKEEP BAKUP
#
# CDP Release 5 2005
# CONCATENATE SOUNDFILES IN ONE BAKUP FILE, WITH SILENCES BETWEEN
# 
# USAGE: housekeep bakup infile1 [infile2 ...] outfile
# 
# 
# 
cdp.housekeep.add_process("bakup", "sndfile", "sndfile", None, "Concatenate soundfiles in one backup file, with silences between.")
params = []
cdp.housekeep.bakup.add_parameters(params)
#
# HOUSEKEEP BATCHEXPAND
#
# CDP Release 5 2005
# EXPAND AN EXISTING BATCHFILE.
# 
# USAGE: housekeep batchexpand mode batch snd1 [snd2 ...] datafile ic oc pc
# 
# BATCH      a batchfile, which uses same kind of param in one of its columns.
# SND1,2...  any number of soundfiles
# IC  is column in batchfile containing input file.
# OC  is column in batchfile containing  output file.
# PC  is column in batchfile containing parameter to be replaced.
# DATAFILE  of param values where 1st param applies to 1st sndfile, 2nd param to 2nd.
# New batchfile created, modelled on original........
# IN MODE 1:
# a) Existing batchfile has only 1 input file.
# b) Same sequence of operations applied to each in-sndfile using each new param.
# (So a 3 line file, with 3 sound inputs, becomes a 9-line file)
# IN MODE 2:
# a) Existing batchfile can operate on different soundfiles.
# Soundfiles in orig batchfile replaced by chosen files, and using new params.
# (So a 3 line file, with 3 sound inputs, becomes a 3-line file)
# 
# 
cdp.housekeep.add_process("batchexpand", "sndfile", "sndfile", 2, "Expand an existing batchfile.")
params = []
cdp.housekeep.batchexpand.add_mode(1, params, "WITH A SINGLE SOUNDFILE")
params = []
cdp.housekeep.batchexpand.add_mode(2, params, "WITH SEVERAL SOUNDFILES")
#
# HOUSEKEEP BUNDLE
#
# CDP Release 5 2005
# LIST FILENAMES IN TEXTFILE FOR SORTING, OR MIXDUMMY.
# 
# USAGE: housekeep bundle mode infile [infile2....] outtextfile
# 
# MODES ARE
# 1) BUNDLE ALL ENTERED FILES
# 2) BUNDLE ALL NON-TEXT FILES ENTERED
# 3) BUNDLE ALL NON-TEXT FILES OF SAME TYPE AS FIRST NON-TEXT FILE
#            e.g. all sndfiles, or all analysis files....
# 4) AS (3), BUT ONLY FILES WITH SAME PROPERTIES
# 5) AS (4), BUT IF FILE1 IS SNDFILE, FILES WITH SAME CHAN COUNT ONLY
# 
# 
cdp.housekeep.add_process("bundle", "anyfile", "anyfile", 5, "List files into a textfile, for sorting, backup or creating mixdummy..")
params = []
cdp.housekeep.bundle.add_mode(1, params, "ANY FILES")
params = []
cdp.housekeep.bundle.add_mode(2, params, "NON-TEXT FILES")
params = []
cdp.housekeep.bundle.add_mode(3, params, "SAME TYPE")
params = []
cdp.housekeep.bundle.add_mode(4, params, "SAME PROPERTIES")
params = []
cdp.housekeep.bundle.add_mode(5, params, "SAME CHANNELS")
#
# HOUSEKEEP CHANS
#
# CDP Release 5 2005
# EXTRACT OR CONVERT CHANNELS OF SOUNDFILE.
# 
# USAGE: housekeep chans 1 infile channo
# OR:    housekeep chans 2 infile 
# OR:    housekeep chans 3 infile outfile channo
# OR:    housekeep chans 4 infile outfile [-p]
# OR:    housekeep chans 5 infile outfile
# 
# MODES ARE
# 1) EXTRACT A CHANNEL
#          channo is channel to extract
#          outfile is named inname_c1 (for channel 1) etc.
# 2) EXTRACT ALL CHANNELS
#          outfiles are named inname_c1 (for channel 1) etc.
# 3) ZERO ONE CHANNEL
#          channo is channel to zero
#          mono file goes to just one side of stereo outfile.
#          stereo file has one channel zeroed out.
# 4) STEREO TO MONO
#          -p inverts phase of 2nd channel before mixing.
# 5) MONO TO STEREO
#          Creates a 2-channel equivalent of mono infile.
# 
# 
"""
cdp.housekeep.add_process("chans", "sndfile", "sndfile", 5, "Extract channels or change channel format of soundfile.")
params = []
cdp.housekeep.chans.add_mode(1, params, "EXTRACT A CHANNEL")
params = []
cdp.housekeep.chans.add_mode(2, params, "EXTRACT ALL CHANNELS")
params = []
cdp.housekeep.chans.add_mode(3, params, "ZERO A CHANNEL")
params = []
cdp.housekeep.chans.add_mode(4, params, "CONVERT STEREO TO MONO")
params = []
cdp.housekeep.chans.add_mode(5, params, "CONVERT MONO TO 'STEREO'")
"""
#
# HOUSEKEEP COPY
#
# CDP Release 5 2005
# MAKE COPIES OF THE INFILE
# 
# USAGE: housekeep copy 1 infile outfile
# OR:    housekeep copy 2 infile count [-i]
# MODES ARE
# 1) COPY ONCE
# 2) COPY MANY
#          Produces N copies of infile X, with names X_001,X_002...
#          COUNT is number of duplicates to produce.
#      -i  ignore existing duplicates (don't overwrite them).
#          default, process halts on discovering a pre-existing file.
# 
# 
cdp.housekeep.add_process("copy", "sndfile", "sndfile", 3, "Make and delete exact copies of a sound.")

params = []
cdp.housekeep.copy.add_mode(1, params, "MAKE A COPY")
params = []
cdp.housekeep.copy.add_mode(2, params, "MAKE MULTIPLE COPIES")
params = []
cdp.housekeep.copy.add_mode(3, params, "DELETE COPIES")
#
# HOUSEKEEP DEGLITCH
#
# CDP Release 5 2005
# ATTEMPT TO DEGLITCH A SOUND.
# 
# USAGE: housekeep deglitch inf outf glitch sil thresh splice window [-s]
# 
# GLITCH maximum duration (ms) of any glitches to find.
# SIL    minimum duration (ms) of 'silence' on either side of glitch.
# THRESH maximum level of 'silence' on either side of glitch.
# SPLICE splicelength (ms) to cutout glitch. Must be < half SILDUR)
#        with THRESH 0 use SPLICE 0. Otherwise SPLICE 0 makes clicks.
# WINDOW windowlen (ms) in which to search for glitches, & 'silence'.
#         very short windows may mistake parts of waveform for 'silence'.
#         Use larger windows to see larger features.
# -s     See details of (possible) glitches found.
# 
# 
cdp.housekeep.add_process("deglitch", "sndfile", "sndfile", None, "Attempt to deglitch a soundfile.")
params = []
cdp.housekeep.deglitch.add_parameters(params)
#
# HOUSEKEEP DISK
#
# CDP Release 5 2005
# DISPLAY AVAILABLE SPACE ON DISK.
# 
# USAGE: housekeep disk anyinfile
# 
# If a sndfile is used, its samplerate will govern space calculations.
# 
# 
cdp.housekeep.add_process("disk", "anyfile", "anyfile", None, "Show available space on disk.")
params = []
cdp.housekeep.disk.add_parameters(params)
#
# HOUSEKEEP ENDCLICKS
#
# CDP Release 5 2005
# REMOVE CLICKS FROM START OR END OF FILE.
# 
# USAGE: housekeep endclicks infile outfile gate splicelen [-b] [-e]
# GATE   level ABOVE which signal accepted : (Range 0-1).
# SPLICE length in mS
# -b     Trim start
# -e     Trim end.
# 
# 
cdp.housekeep.add_process("endclicks", "sndfile", "sndfile", None, "Remove clicks from start or end of file.")
params = []
cdp.housekeep.endclicks.add_parameters(params)
#
# HOUSEKEEP EXTRACT
#
# CDP Release 5 2005
# USAGE: housekeep extract 
#        1 inf [-ggate] [-sS] [-eE] [-tT] [-hH] [-bB] [-iI] [-lL] [-wW] [-n]
# OR:    2 inf outf             OR: 3 inf outf [-ggate] [-ssplice] [-b] [-e]
# OR:    4 inf outf shift       OR: 5 inf outf valsfile
# OR:    6 inf gate endgate threshold baktrak initlevel minsize gatewin
# MODE 1) CUT OUT & KEEP SIGNIFICANT EVENTS FROM INPUT SNDFILE.
# -g  GATE level (G) above which sounds accepted : Range:0-1 (default 0).
# -s  SPLICE LENGTH in mS (default 15mS)
# -e  END-CUTOFF level (E) below which END of sound cut.(If 0, defaults to GATE).
# -t  THRESHOLD (T) If segment level never exceeds threshold,not kept(default 0)
# -h  HOLD sound till S sectors BEFORE START of next segment.(default 0)
# -b  KEEP B sects prior to gate-on, if level there > I (see below). Max B is 64.
# -i  INITIAL level (I). Use with -b flag.
# -l  Min LENGTH of events to keep (secs).
# -w  GATE_WINDOW Gates off only if level < gate for W+1 sectors. (default 0).
# -n  STOP if NAME of EXISTING sndfile generated. Default: ignore and continue.
# MODE 2) PREVIEW: make envel as 'sound'. View to get params for CUT OUT & KEEP.
# MODE 3) TOP AND TAIL: REMOVE LOW LEVEL SIGNAL FROM START & END OF SOUND.
#  GATE   level ABOVE which signal accepted : (Range 0-1 : default 0).
#  SPLICE length in mS (default 15mS) : -b Don't trim start : -e Don't trim end.
# MODE 4) RECTIFY: SHIFT ENTIRE SIGNAL TO ELIMINATE DC DRIFT.
# MODE 5) MODIFY 'BY HAND'. This process is no longer available.
# MODE 6) GET ONSET TIMES:gate,end-cutoff,thresh,keep,init-lvl,minlen,gate-windw.
# 
# 
cdp.housekeep.add_process("extract", "sndfile", "sndfile", 4, "Extract significant sound from recording, top & tail, remove glitches etc.")
params = []
cdp.housekeep.extract.add_mode(1, params, "GATED EXTRACTION")
params = []
cdp.housekeep.extract.add_mode(2, params, "PREVIEW EXTRACTION")
params = []
cdp.housekeep.extract.add_mode(3, params, "TOP AND TAIL")
params = []
cdp.housekeep.extract.add_mode(4, params, "REMOVE DC")
#
# HOUSEKEEP GATE
#
# CDP Release 5 2005
# CUT FILE AT ZERO AMPLITUDE POINTS.
# 
# USAGE: housekeep gate infile outfile [-zzerocnt]
# 
# zerocnt: number of consecutive zero samples (per channel)
#          to indicate a silent gap in sound, where it can be cut.
# 
# 
cdp.housekeep.add_process("gate", "sndfile", "sndfile", None, "Cut file at zero amplitude points.")
params = []
cdp.housekeep.gate.add_parameters(params)
#
# HOUSEKEEP REMOVE
#
# CDP Release 5 2005
# REMOVE EXISTING COPIES OF A FILE 
# 
# USAGE: housekeep remove filename [-a]
# 
#          Deletes any copies of filename X, having names X_001,X_002...
#          No checks are made that these ARE COPIES of file X!!
#      -a  Program checks all names in numbered sequence.
#          In standard case, once a numbered file is missing,
#          program checks for 10 more named files before halting.
#          Setting -a flag forces program to search for all possible
#          duplicate filenames. This may take some time.
# 
# 
cdp.housekeep.add_process("remove", "sndfile", "sndfile", None, "Remove existing copies of a file.")
params = []
cdp.housekeep.remove.add_parameters(params)
#
# HOUSEKEEP RESPEC
#
# CDP Release 5 2005
# ALTER THE SPECIFICATION OF A SOUNDFILE.
# 
# USAGE: housekeep respec 1 infile outfile new_samplerate
# OR:    housekeep respec 2 infile outfile
# OR:    housekeep respec 3 infile outfile [-ssrate] [-cchannels]
# MODES ARE
# 
# 1) RESAMPLE  at some different sampling rate.
#            New sampling rate must be one of...
#            96000,88200,48000,24000,44100,22050,32000,16000
# 
# 2) CONVERT FROM INTEGER TO FLOAT SAMPLES, OR VICE VERSA
# 
# 3) CHANGE PROPERTIES OF SOUND: (USE WITH CAUTION!!)
#       SRATE is the new sample rate to impose.
#            NB: this does NOT RESAMPLE the data.
#            Simply causes original data to be read at different srate.
#            Sound has same no of samples, but different duration,
#            and will appear to be transposed in pitch.
#       CHANNELS is the new channel count to impose.
#            NB: this does NOT RECHANNEL the data.
#            Hence e.g. a stereo file will appear twice as long.
# 
# 
cdp.housekeep.add_process("respec", "sndfile", "sndfile", 3, "Change sample rate, format or properties of a soundfile (CARE!!).")
params = []
cdp.housekeep.respec.add_mode(1, params, "CHANGE SAMPLING RATE")
params = []
cdp.housekeep.respec.add_mode(2, params, "CONVERT SAMPLE FORMAT")
params = []
cdp.housekeep.respec.add_mode(3, params, "CHANGE PROPERTIES")
#
# HOUSEKEEP SORT
#
# CDP Release 5 2005
# SORT FILES LISTED IN A TEXTFILE.
# 
# USAGE: housekeep sort 1   listfile
# OR:    housekeep sort 2-3 listfile small large step [-l]
# OR:    housekeep sort 4   listfile [-l]
# OR:    housekeep sort 5   listfile
# LISTFILE is a textfile, a list of names of files to be sorted.
# 
# MODES ARE
# 1) SORT BY FILETYPE
#       Sorts files into different types.
#       Lists appropriate filenames in textfiles with extensions.. 
#       .mot  mono sndfiles           .stt  stereo sndfiles
#       .qtt  4-channel sndfiles      .ant  analysis files
#       .pct  binary pitchdata files  .fot  binary formant files
#       .ent  binary envelope files   .trt  binary transposition files
#       .ott  any other files
# 2) SORT BY SRATE
#       Sorts any soundfiles to different sampling rates.
#       Lists appropriate filenames in textfiles with extensions.. 
#       .24  for 24000            .44  for 44100              ETC
# 3) SORT BY DURATION
#       Sorts any soundfiles to different lengths.
#       If the listfile is 'list' or 'list.xxx' sorted file is 'list.len'.
#       SMALL is max size of smallest files. (secs)
#       LARGE is min size of largest files. (secs)
#       STEP  is size-steps between file types. (secs)
#       -l causes file durations not to be written to outfile.
# 4) SORT BY LOG DURATION
#       The same, except STEP is duration ratio between file types.
#       -l causes file durations not to be written to outfile.
# 5) SORT INTO DURATION ORDER
#       Sorts any sndfiles into duration order.
#       If the listfile is 'list' or 'list.xxx' sorted file is 'list.len'.
#       -l causes file durations not to be written to outfile.
# 6) FIND ROGUES
#       Sort out any non- or invalid soundfiles.
# 
# 
cdp.housekeep.add_process("sort", "textfile", "textfile", 6, "Sort files listed in a textfile.")
params = []
cdp.housekeep.sort.add_mode(1, params, "BY FILETYPE")
params = []
cdp.housekeep.sort.add_mode(2, params, "BY SAMPLING RATE")
params = []
cdp.housekeep.sort.add_mode(3, params, "BY DURATION")
params = []
cdp.housekeep.sort.add_mode(4, params, "BY LOG DURATION")
params = []
cdp.housekeep.sort.add_mode(5, params, "INTO DURATION ORDER")
params = []
cdp.housekeep.sort.add_mode(6, params, "FIND ROGUES")
#
# SFEDIT
#
#
# SFEDIT CUT
#
# CDP Release 5 2005
# CUT & KEEP A SEGMENT OF A SOUND.
# 
# USAGE: sfedit cut mode infile outfile start end [-wsplice]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# START  is time in infile where segment to keep begins.
# END    is time in infile where segment to keep ends.
# SPLICE  splice window in milliseconds (default: 15)
# 
# 
cdp.sfedit.add_process("cut", "sndfile", "sndfile", 3, "Cutout and keep a segment of a soundfile.")
params = [  ["start", 0, None, "time in infile where segment to keep begins"],
            ["end", 0, None, "time in infile where segment to keep ends"],
            ["-w", 0, None, "splice window in milliseconds (default: 15)"],
        ]
cdp.sfedit.cut.add_mode(1, params, "TIME IN SECONDS")
cdp.sfedit.cut.add_mode(2, params, "TIME AS SAMPLE COUNT")
cdp.sfedit.cut.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT CUTEND
#
# CDP Release 5 2005
# CUT & KEEP END PORTION OF A SOUND.
# 
# USAGE: sfedit cutend mode infile outfile length [-wsplice]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# LENGTH is length of sound to keep, ending at end of input sound.
# SPLICE  splice window in milliseconds (default: 15)
# 
# 
cdp.sfedit.add_process("cutend", "sndfile", "sndfile", 3, "Cutout and keep end part of a soundfile.")
params = []
cdp.sfedit.cutend.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.cutend.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.cutend.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT CUTMANY
#
# CDP Release 5 2005
# CUT & KEEP SEVERAL SEGMENTS OF A SOUND.
# 
# USAGE: sfedit cutmany mode infile outfile cuttimes splice
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# CUTTIMES is a file of time-pairs of the start and end of each segment
# SPLICE  splice window in milliseconds
# 
# 
cdp.sfedit.add_process("cutmany", "sndfile", "sndfile", 3, "Cut and keep several segments of a sound.")
params = []
cdp.sfedit.cutmany.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.cutmany.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.cutmany.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT EXCISE
#
# CDP Release 5 2005
# DISCARD SPECIFIED CHUNK OF SOUND, CLOSING UP THE GAP.
# 
# USAGE: sfedit excise mode infile outfile start end [-wsplice]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# START   starttime of excision.
# END     endtime of excision.
# SPLICE  splice window in milliseconds (default: 15)
# 
# 
cdp.sfedit.add_process("excise", "sndfile", "sndfile", 3, "Remove segment of soundfile, and close up gap.")
params = []
cdp.sfedit.excise.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.excise.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.excise.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT EXCISES
#
# CDP Release 5 2005
# DISCARD SPECIFIED CHUNKS OF A SOUND, CLOSING UP THE GAPS.
# 
# USAGE: sfedit excises mode infile outfile excisefile [-wsplice]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# EXCISEFILE is a texfile with (paired) start & end times of chunks
#            to be removed. These must be in increasing time order.
# SPLICE  splice window in milliseconds (default: 15)
# 
# 
cdp.sfedit.add_process("excises", "sndfile", "sndfile", 3, "Remove segments of soundfile, and close up gaps.")
params = []
cdp.sfedit.excises.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.excises.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.excises.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT INSERT
#
# CDP Release 5 2005
# INSERT A 2nd SOUND INTO AN EXISTING SOUND.
# 
# USAGE: sfedit insert mode infile insert outfile time [-wsplice] [-llevel] [-o]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# TIME    at which 2nd file to be inserted in 1st file.
# SPLICE  splice window in milliseconds (default: 15)
# LEVEL   gain multiplier on inserted file. (default 1.0).
# -o      overwrite equivalent duration of original file with inserted file.
#         (default .. insertion pushes infile apart).
# 
# 
cdp.sfedit.add_process("insert", "sndfile", "sndfile", 3, "Insert 2nd sound into first (overwriting or spreading 1st sound).")
params = []
cdp.sfedit.insert.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.insert.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.insert.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT INSIL
#
# CDP Release 5 2005
# INSERT SILENCE INTO AN EXISTING SOUND.
# 
# USAGE: sfedit insil mode infile outfile time duration [-wsplice] [-o] [-s]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# TIME     at which silence to be inserted in infile.
# DURATION of inserted silence.
# SPLICE   splice window in milliseconds (default: 15)
# -o       overwrites original file with the silence.
#          (default .. silence pushes infile apart).
# -s       retains any silence written over file end.
#          (default .. rejects silence added at file end).
# 
# 
cdp.sfedit.add_process("insil", "sndfile", "sndfile", 3, "Insert silence into sound (overwriting or spreading sound).")
params = []
cdp.sfedit.insil.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.insil.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.insil.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT JOIN
#
# CDP Release 5 2005
# JOIN FILES TOGETHER, ONE AFTER ANOTHER.
# 
# USAGE: sfedit join infile1 [infile2 infile3....] outfile [-wsplice] [-b] [-e] 
# 
# SPLICE duration of splices, in MS (default 15)
# -b     splices start of first file
# -e     splices end of last file
# 
# 
cdp.sfedit.add_process("join", "sndfile", "sndfile", None, "Join sounds together, one after another.")
params = []
cdp.sfedit.join.add_parameters(params)
#
# SFEDIT JOINDYN
#
# CDP Release 5 2005
# JOIN FILES TOGETHER, ONE AFTER ANOTHER, IN A PATTERN, WITH LOUDNESS PATTERN
# 
# USAGE: sfedit join inf1 [inf2...] outf pattern [-wsplice] [-b] [-e] 
# 
# PATTERN  file of sequence of numbers = sequence of input files to use,
#          each paired with a gain value for that pattern item
# SPLICE duration of splices, in MS (default 15)
# -b     splices start of first file
# -e     splices end of last file
# 
# 
cdp.sfedit.add_process("joindyn", "sndfile", "sndfile", None, "Join soundfiles in loudness-patterned sequence.")
params = []
cdp.sfedit.joindyn.add_parameters(params)
#
# SFEDIT JOINSEQ
#
# CDP Release 5 2005
# JOIN FILES TOGETHER, ONE AFTER ANOTHER, IN A PATTERN
# 
# USAGE: sfedit join infile1 [infile2 ....] outfile pattern [-wsplice] [-mmaxlen] [-b] [-e] 
# 
# PATTERN file contains sequence of numbers = sequence of input files to use
# SPLICE duration of splices, in MS (default 15)
# MAXLEN maximum number of items in pattern to use
# -b     splices start of first file
# -e     splices end of last file
# 
# 
cdp.sfedit.add_process("joinseq", "sndfile", "sndfile", None, "Join soundfiles in patterned sequence.")
params = []
cdp.sfedit.joinseq.add_parameters(params)
#
# SFEDIT MASKS
#
# CDP Release 5 2005
# MASK SPECIFIED CHUNKS OF A SOUND, WITH SILENCE.
# 
# USAGE: sfedit masks mode infile outfile excisefile [-wsplice]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# EXCISEFILE is a texfile with (paired) start & end times of chunks
#            to be masked. These must be in increasing time order.
# SPLICE  splice window in milliseconds (default: 15)
# 
# 
cdp.sfedit.add_process("masks", "sndfile", "sndfile", 3, "Mask specified chunks of a sound, with silence.")
params = []
cdp.sfedit.masks.add_mode(1, params, "TIME AS SECONDS")
params = []
cdp.sfedit.masks.add_mode(2, params, "TIME AS SAMPLE COUNT")
#
# SFEDIT NOISECUT
#
# CDP Release 5 2005
# SUPPRESS NOISE IN A (MONO) SOUND FILE: REPLACE BY SILENCE.
# 
# USAGE: sfedit noisecut infile outfile splicelen noisfrq maxnoise mintone [-n]
# 
# SPLICELEN    duration of splices, in MS
# NOISEFRQ     frequency above which signal regarded as noise (try 6000 Hz)
# MAXNOISE     max duration of any noise segments permitted to remain (NOT replaced)
# MINTONE      min duration of any non-noise segments to be retained.
# -n           retain noise rather than non-noise
# 
# 
cdp.sfedit.add_process("noisecut", "sndfile", "sndfile", None, "Suppress noise in a (mono) soundfile, replacing with silence.")
params = []
cdp.sfedit.noisecut.add_parameters(params)
#params = []
#cdp.sfedit.noisecut.add_mode(3, params, "TIME AS GROUPED SAMPLES")
#
# SFEDIT RANDCHUNKS
#
# CDP Release 5 2005
# CUT CHUNKS FROM FILE, RANDOMLY.
# 
# USAGE:
# sfedit randchunks infile chunkcnt minchunk [-mmaxchunk] [-l] [-s]
# 
# Names of outfiles will be 'infilename' truncated by 1 character,
#       with a number added, starting from zero.
# Chunkcnt is number of chunks to cut.
# Minchunk is minimum length of chunks.
# 
# -m    maxchunk is maximum length of chunks.
# -l    chunks chosen are evenly distributed over file
#       (default: random distribution)
# -s    all chunks start at beginning of file
# 
# 
cdp.sfedit.add_process("randchunks", "sndfile", "sndfile", None, "Cut chunks from a soundfile, randomly.")
params = []
cdp.sfedit.randchunks.add_parameters(params)
#
# SFEDIT RANDCUTS
#
# CDP Release 5 2005
# CUT FILE INTO PIECES WITH CUTS AT RANDOM TIMES.
# 
# USAGE: sfedit randcuts infile average-chunklen scattering
# 
# Names of outfiles will be infilename truncated by 1 character,
#       with a number added, starting from zero.
# average-chunklen is average length of chunks cut.
# scattering       is variation in length of cuts : range 0-8
# 
# 
cdp.sfedit.add_process("randcuts", "sndfile", "sndfile", None, "Cut soundfile into pieces, with cuts at random times.")
params = []
cdp.sfedit.randcuts.add_parameters(params)
#
# SFEDIT REPLACE
#
# CDP Release 5 2005
# INSERT A 2nd SOUND INTO AN EXISTING SOUND, REPLACING PART OF ORIGINAL SOUND.
# 
# USAGE: sfedit replace infile insert outfile time endtime [-wsplice] [-llevel]
# 
# TIME    at which 2nd file to be inserted in 1st file.
# ENDTIME endtime of segment in original file to be replaced.
# SPLICE  splice window in milliseconds (default: 15)
# LEVEL   gain multiplier on inserted file. (default 1.0).
# 
# 
cdp.sfedit.add_process("replace", "sndfile", "sndfile", None, "Insert a 2nd sound into an existing sound, replacing part of original.")
params = []
cdp.sfedit.replace.add_parameters(params)
#
# SFEDIT SYLLABLES
#
# CDP Release 5 2005
# CUT TEXT INTO ITS CONTIGUOUS SYLLABLES.
# 
# USAGE: sfedit syllables mode infil outfil cuttimes dovetail splice [-p]
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count (rounded to multiples of channel-cnt).
# 3) Time as grouped-sample count (e.g. 3 = 3 stereo-pairs).
# 
# CUTTIMES is starttime of syllables, and end time of last syllable.
# DOVETAIL is time in milliseconds to allow for syllable overlap.
# SPLICE  splice window in milliseconds.
# -p   Forces process to cut PAIRS of syllables.
# 
# 
cdp.sfedit.add_process("syllables", "sndfile", "sndfile", 3, "Separate out vocal syllables.")
params = []
cdp.sfedit.syllables.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.syllables.add_mode(2, params, "TIME AS SAMPLE COUNT")
params = []
cdp.sfedit.syllables.add_mode(3, params, "TIME AS GROUPED SAMPLE CNT")
#
# SFEDIT ZCUT
#
# CDP Release 5 2005
# CUT & KEEP SEG OF MONO SOUND, CUTTING AT ZERO-CROSSINGS (NO SPLICES).
# 
# USAGE: sfedit zcut mode infile outfile start end
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count.
# START  is (approx) time in infile where segment to keep begins.
# END    is (approx) time in infile where segment to keep ends.
# 
# 
cdp.sfedit.add_process("zcut", "sndfile", "sndfile", 2, "Cutout & keep a segment of soundfile, with no splicing.")
params = []
cdp.sfedit.zcut.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.zcut.add_mode(2, params, "TIME AS SAMPLE COUNT")
#
# SFEDIT ZCUTS
#
# CDP Release 5 2005
# CUT & KEEP SEGS OF MONO SOUND, CUTTING AT ZERO-CROSSINGS (NO SPLICES).
# 
# USAGE: sfedit zcuts mode infile outfile cuttimes
# 
# MODES ARE
# 1) Time in seconds.
# 2) Time as sample count.
# CUTTIMES is a file of time-pairs of the start and end of each segment
# 
# 
cdp.sfedit.add_process("zcuts", "sndfile", "sndfile", 2, "Cutout & keep segments of soundfile, with no splicing.")
params = []
cdp.sfedit.zcuts.add_mode(1, params, "TIME IN SECONDS")
params = []
cdp.sfedit.zcuts.add_mode(2, params, "TIME AS SAMPLE COUNT")
#
# SNDINFO
#
#
# SNDINFO CHANDIFF
#
# CDP Release 5 2005
# COMPARE CHANNELS IN A STEREO SOUNDFILE
# 
# USAGE: sndinfo chandiff infile [-tthreshold] [-ncnt]
# 
# THRESHOLD  max permissible difference in data values.
# CNT        MAX NUMBER of differences to accept (default 1).
#    NB: The output sample display is counted in sample-pairs.
# 
# 
cdp.sndinfo.add_process("chandiff", "sndfile", "sndfile", None, "Do channels of stereo file differ?")
params = []
cdp.sndinfo.chandiff.add_parameters(params)
#
# SNDINFO DIFF
#
# CDP Release 5 2005
# COMPARE 2 SOUND,ANALYSIS,PITCH,TRANSPOSITION,ENVELOPE OR FORMANT FILES
# 
# USAGE: sndinfo diff infile1 infile2 [-tthreshold] [-ncnt] [-l] [-c]
# 
# THRESHOLD  max permissible difference in data values:
# CNT        MAX NUMBER of differences to accept (default 1).
# -l         continue, even if files are not same LENGTH
# -c         continue, even if (snd)files don't have same no of CHANNELS
# 
# This process works with binary (non-text) files only.
# 
# 
cdp.sndinfo.add_process("diff", "binary6", "binary6", None, "Do two (non-text) files differ?")
params = []
cdp.sndinfo.diff.add_parameters(params)
#
# SNDINFO FINDHOLE
#
# CDP Release 5 2005
# FIND LARGEST LOW LEVEL HOLE IN A SOUNDFILE
# 
# USAGE: sndinfo findhole infile [-tthreshold]
# 
# THRESHOLD  hole only if level falls and stays below threshold (default: 0).
# 
# 
cdp.sndinfo.add_process("findhole", "sndfile", "sndfile", None, "Locate largest area of low-level signal in sound.")
params = []
cdp.sndinfo.findhole.add_parameters(params)
#
# SNDINFO LEN
#
# CDP Release 5 2005
# DISPLAY DURATION OF A SNDFILING-SYSTEM FILE
# 
# USAGE: sndinfo len infile
# 
# 
cdp.sndinfo.add_process("len", "binary6", "binary6", None, "Show duration of sound, analysis, envelope, pitch, formant or transposition file.")
params = []
cdp.sndinfo.len.add_parameters(params)
#
# SNDINFO LENS
#
# CDP Release 5 2005
# LIST DURATIONS OF SEVERAL SNDFILING-SYSTEM FILES
# 
# USAGE: sndinfo lens infile [infile2..]
# 
# 
cdp.sndinfo.add_process("lens", "sndfile", "sndfile", None, "List durations of soundfiles.")
params = []
cdp.sndinfo.lens.add_parameters(params)
#
# SNDINFO LOUDCHAN
#
# CDP Release 5 2005
# FIND LOUDEST CHANNEL IN A STEREO SOUNDFILE
# 
# USAGE: sndinfo loudchan infile
# 
# 
cdp.sndinfo.add_process("loudchan", "sndfile", "sndfile", None, "Show loudest channel of stereo file.")
params = []
cdp.sndinfo.loudchan.add_parameters(params)
#
# SNDINFO MAXI
#
# CDP Release 5 2005
# LIST LEVELS OF SEVERAL SOUNDFILES
# 
# USAGE: sndinfo maxi infile infile2 [infile3..] outfile
# 
# 
cdp.sndinfo.add_process("maxi", "sndfile", "sndfile", None, "List levels of several soundfiles.")
params = []
cdp.sndinfo.maxi.add_parameters(params)
#
# SNDINFO MAXSAMP
#
# CDP Release 5 2005
# FIND MAXIMUM SAMPLE IN SOUNDFILE OR BINARY DATA FILE
# 
# USAGE: sndinfo maxsamp infile [-f]
# -f   Force file to be scanned
#      (Ignore any header info about max sample)
# 
# 
cdp.sndinfo.add_process("maxsamp", "binary6", "binary6", None, "Show level and position of maximum sample.")
params = []
cdp.sndinfo.maxsamp.add_parameters(params)
#
# SNDINFO MAXSAMP2
#
# CDP Release 5 2005
# FIND MAXIMUM SAMPLE WITHIN TIMERANGE IN SOUNDFILE
# 
# USAGE: sndinfo maxsamp2 infile start end
# 
# start  starttime of search in file
# end    endtime of search in file
# 
# 
cdp.sndinfo.add_process("maxsamp2", "binary6", "binary6", None, "Show level and position of maximum sample within specified time points.")
params = []
cdp.sndinfo.maxsamp2.add_parameters(params)
#
# SNDINFO PRNTSND
#
# CDP Release 5 2005
# PRINT SOUND SAMPLE DATA TO A TEXTFILE
# 
# USAGE: sndinfo prntsnd infile outtextfile starttime endtime
# 
# CARE!!! large quantities of data.
# 
# 
cdp.sndinfo.add_process("prntsnd", "sndfile", "sndfile", None, "Print sample values (CARE!! LARGE FILES)")
params = []
cdp.sndinfo.prntsnd.add_parameters(params)
#
# SNDINFO PROPS
#
# CDP Release 5 2005
# DISPLAY PROPERTIES OF A SNDFILING-SYSTEM FILE
# 
# USAGE: sndinfo props infile
# 
# 
cdp.sndinfo.add_process("props", "binary6", "binary6", None, "Show properties of file.")
params = []
cdp.sndinfo.props.add_parameters(params)
#
# SNDINFO SMPTIME
#
# CDP Release 5 2005
# CONVERT SAMPLE COUNT TO TIME IN SOUNDFILE
# 
# USAGE: sndinfo smptime infile samplecnt [-g]
# 
# -g   sample count is count of GROUPED samples
#      e.g. stereo file: sample-PAIRS counted.
# 
# 
cdp.sndinfo.add_process("smptime", "sndfile", "sndfile", None, "Convert a sample-position in file to a time.")
params = []
cdp.sndinfo.smptime.add_parameters(params)
#
# SNDINFO SUMLEN
#
# CDP Release 5 2005
# SUM DURATIONS OF SEVERAL SNDFILING-SYSTEM FILES
# 
# USAGE: sndinfo sumlen infile infile2 [infile3..] [-ssplicelen]
# 
#       SPLICELEN is in milliseconds. (Default: 15ms)
# 
# 
cdp.sndinfo.add_process("sumlen", "sndfile", "sndfile", None, "Sum durations of soundfiles.")
params = []
cdp.sndinfo.sumlen.add_parameters(params)
#
# SNDINFO TIMEDIFF
#
# CDP Release 5 2005
# FIND DIFFERENCE IN DURATION OF TWO SOUND FILES
# 
# USAGE: sndinfo timediff infile1 infile2
# 
# 
cdp.sndinfo.add_process("timediff", "sndfile", "sndfile", None, "Find difference in duration of two soundfiles.")
params = []
cdp.sndinfo.timediff.add_parameters(params)
#
# SNDINFO TIMESMP
#
# CDP Release 5 2005
# CONVERT TIME TO SAMPLE COUNT IN SOUNDFILE
# 
# USAGE: sndinfo timesmp infile time [-g]
# 
# -g   sample count is count of GROUPED samples
#      e.g. stereo file: sample-PAIRS counted.
# 
# 
cdp.sndinfo.add_process("timesmp", "sndfile", "sndfile", None, "Convert a time to a sample-position in file.")
params = []
cdp.sndinfo.timesmp.add_parameters(params)
#
# SNDINFO UNITS
#
# CDP Release 5 2005
# CONVERT BETWEEN DIFFERENT UNITS
# 
# USAGE: sndinfo units mode value
# 
#                            MODES ARE
# 
#        PITCH                  INTERVAL                       SPEED
#        -----                  --------                       -----
# (1) MIDI to FRQ   (7)  FRQ RATIO  to SEMITONES (16) FRQ RATIO  to TIME RATIO
# (2) FRQ  to MIDI  (8)  FRQ RATIO  to INTERVAL  (17) SEMITONES  to TIME RATIO
# (3) NOTE to FRQ   (9)  INTERVAL   to FRQ RATIO (18) OCTAVES    to TIME RATIO
# (4) NOTE to MIDI  (10) SEMITONES to FRQ RATIO  (19) INTERVAL   to TIME RATIO
# (5) FRQ to NOTE   (11) OCTAVES    to FRQ RATIO (20) TIME RATIO to FRQ RATIO
# (6) MIDI to NOTE  (12) OCTAVES   to SEMITONES  (21) TIME RATIO to SEMITONES
#                   (13) FRQ RATIO to OCTAVES    (22) TIME RATIO to OCTAVES
#                   (14) SEMITONES to OCTAVES    (23) TIME RATIO to INTERVAL
#                   (15) SEMITONES to INTERVAL
# 
#                                 LOUDNESS
#                                 --------
#                   (24) GAIN FACTOR to DB GAIN
#                   (25) DB GAIN     to GAIN FACTOR
# 
# NOTE REPRESENTATION ..... A1 = A in octave 1
#                           Ebu4 is E flat,   + (Up) quartertone  in octave 4
#                           F#d-2 is F sharp, - (Dn) quartertone, in octave -2
# 
# INTERVAL REPRESENTATION.. 3 = a 3rd     -m3 = minor 3rd DOWN
#                           m3u = minor 3rd + (Up) quartertone
#                           #4d = tritone   - (Dn) quartertone
#                           15  = a fifteenth (max permissible interval)
# 
# 
cdp.sndinfo.add_process("units", "anyfile", "anyfile", 25, "Convert values from one type of unit to another.")
params = []
cdp.sndinfo.units.add_mode(1, params, "MIDI to FRQ")
params = []
cdp.sndinfo.units.add_mode(2, params, "FRQ to MIDI")
params = []
cdp.sndinfo.units.add_mode(3, params, "NOTE to FRQ")
params = []
cdp.sndinfo.units.add_mode(4, params, "NOTE to MIDI")
params = []
cdp.sndinfo.units.add_mode(5, params, "FRQ to NOTE")
params = []
cdp.sndinfo.units.add_mode(6, params, "MIDI to NOTE")
params = []
cdp.sndinfo.units.add_mode(7, params, "FRQ RATIO to SEMITONES")
params = []
cdp.sndinfo.units.add_mode(8, params, "FRQ RATIO to INTERVAL")
params = []
cdp.sndinfo.units.add_mode(9, params, "INTERVAL to FRQ RATIO")
params = []
cdp.sndinfo.units.add_mode(10, params, "SEMITONES to FRQ RATIO")
params = []
cdp.sndinfo.units.add_mode(11, params, "OCTAVES to FRQ RATIO")
params = []
cdp.sndinfo.units.add_mode(12, params, "OCTAVES to SEMITONES")
params = []
cdp.sndinfo.units.add_mode(13, params, "FRQ RATIO to OCTAVES")
params = []
cdp.sndinfo.units.add_mode(14, params, "SEMITONES to OCTAVES")
params = []
cdp.sndinfo.units.add_mode(15, params, "SEMITONES to INTERVAL")
params = []
cdp.sndinfo.units.add_mode(16, params, "FRQ RATIO to TIME RATIO")
params = []
cdp.sndinfo.units.add_mode(17, params, "SEMITONES to TIME RATIO")
params = []
cdp.sndinfo.units.add_mode(18, params, "OCTAVES to TIME RATIO")
params = []
cdp.sndinfo.units.add_mode(19, params, "INTERVAL to TIME RATIO")
params = []
cdp.sndinfo.units.add_mode(20, params, "TIME RATIO to FRQ RATIO")
params = []
cdp.sndinfo.units.add_mode(21, params, "TIME RATIO to SEMITONES")
params = []
cdp.sndinfo.units.add_mode(22, params, "TIME RATIO to OCTAVES")
params = []
cdp.sndinfo.units.add_mode(23, params, "TIME RATIO to INTERVAL")
params = []
cdp.sndinfo.units.add_mode(24, params, "GAIN FACTOR to dB GAIN")
params = []
cdp.sndinfo.units.add_mode(25, params, "dB GAIN to GAIN FACTOR")
#
# SNDINFO ZCROSS
#
# CDP Release 5 2005
# DISPLAY FRACTION OF ZERO-CROSSINGS IN FILE
# 
# USAGE: sndinfo ZCROSS infile [-sstarttime -eendtime]
# 
# 
cdp.sndinfo.add_process("zcross", "sndfile", "sndfile", None, "Display fraction of zero-crossings in a sound.")
params = []
cdp.sndinfo.zcross.add_parameters(params)
#
# SUBMIX
#
#
# SUBMIX ADDTOMIX
#
# CDP Release 5 2005
# ADD SOUNDFILES (at max level and time end-of-file) TO EXISTING MIXFILE.
# 
# USAGE: submix addtomix mixfile sndfile1 [sndfile2 ........] outfile
# 
# 
cdp.submix.add_process("addtomix", "mixfile", "mixfile", None, "Add soundfiles to an existing mixfile.")
params = []
cdp.submix.addtomix.add_parameters(params)
#
# SUBMIX ATSTEP
#
# CDP Release 5 2005
# CONVERT LISTED SNDFILES TO BASIC MIXFILE WITH FIXED TIMESTEP BETWEEN ENTRIES
# 
# USAGE: submix atstep infile1 infile2 [infile3..] outmixfile step
# 
# STEP is time, in seconds, between entry of each file.
# 
# 
# 
cdp.submix.add_process("atstep", "textfile", "textfile", None, "Convert a list of soundfiles to a mixfile.")
params = []
cdp.submix.atstep.add_parameters(params)
#
# SUBMIX ATTENUATE
#
# CDP Release 5 2005
# ALTER THE OVERALL LEVEL OF A MIXFILE.
# 
# USAGE:  submix attenuate inmixfile outmixfile gainval [-sstartline] [-eendline]
# 
# GAINVAL must be > 0.0
# STARTLINE: line at which attenuation begins (default: 1st in file)
# ENDLINE  : line at which attenuation ends  (default: last in file).
# You can test the overall level of a mix with 'submix getlevel'
# 
# 
cdp.submix.add_process("attenuate", "mixfile", "mixfile", None, "Alter the overall level of a mixfile.")
params = []
cdp.submix.attenuate.add_parameters(params)
#
# SUBMIX BALANCE
#
# CDP Release 5 2005
# MIX BETWEEN 2 SNDFILES USING A BALANCE FUNCTION.
# 
# USAGE: submix balance sndfile1 sndfile2 outfile
#                             [-kbalance] [-bstart] [-eend]
# 
# (files may or may not have different number of channels).
# 
# BALANCE ...Describes the relative level of the two sounds. (Range 0-1)
# ......File 1 level is multiplied by the balance function.
# ......File 2 level is multiplied by the inverse of the balance function.
# Balance may vary over time.
# 
# START .....Start the mix at the time specified.
# END........Stop the mix at the time specified.
# 
# 
cdp.submix.add_process("balance", "sndfiles", "sndfiles", None, "Mix between 2 soundfiles, using a balance function.")
params = []
cdp.submix.balance.add_parameters(params)
#
# SUBMIX CROSSFADE
#
# CDP Release 5 2005
# QUICK CROSSFADE BETWEEN SNDFILES (WITH SAME NUMBER OF CHANNELS).
# 
# USAGE: submix crossfade 1 sndfile1 sndfile2 outfile
# 		[-sSTAGGER] [-bBEGIN] [-eEND]
# OR:    submix crossfade 2 sndfile1 sndfile2 outfile
# 		[-sSTAGGER] [-bBEGIN] [-eEND] [-pPOWFAC]
# 
# MODES ARE...
# 1) Linear crossfade.
# 2) Cosinusiodal crossfade
# 
# Crossfade is from sndfile1 towards sndfile2.
# 
# STAGGER   2nd file starts 'stagger' secs. after 1st. (Default: 0)
# BEGIN     crossfade starts at BEGIN secs. (>Stagger) (Default: 0)
# END       crossfade ends at END secs. (>Begin) (Default: end of shortest file)
#           If crossfade ends before end of file2, remainder of file2 plays on.
# POWFAC    crossfade skew.
#           if powfac = 1, cosinusoidal-crossfade is normal.
#           in range 0.12 - 1, cosin-fade begins rapidly then slows.
#           in range 1 - 8, cosin-fade begins slowly, then speeds up.
# 
# Stagger approximated in c. hundredths of a sec. For more precise stagger, 
# splice silence to start of sndfile2 & use stagger 0 (or use 'submix mix').
# 
# (Only spectral morphing will create true morph between 2 sounds).
# 
# 
cdp.submix.add_process("crossfade", "sndfile", "sndfile", 2, "Quick crossfade between 2 soundfiles (with same no. of channels).")
params = []
cdp.submix.crossfade.add_mode(1, params, "LINEAR")
params = []
cdp.submix.crossfade.add_mode(2, params, "COSINUSOIDAL")
#
# SUBMIX DUMMY
#
# CDP Release 5 2005
# CONVERT A LIST OF SNDFILES INTO A BASIC MIXFILE (FOR EDITING)
# 
# USAGE: submix dummy mode infile1 infile2 [infile3..] mixfile
# mode 1 - all files start at time zero.
# mode 2 - each file starts where previous file ends.
# 
# 
cdp.submix.add_process("dummy", "sndlist", "sndlist", 2, "Convert list of sound names to basic mixfile (for editing).")
params = []
cdp.submix.dummy.add_mode(1, params, "ALL FILES START AT TIME ZERO")
params = []
cdp.submix.dummy.add_mode(2, params, "FILES START WHERE PREVIOUS ENDS")
#
# SUBMIX FADERS
#
# CDP Release 5 2005
# MIX SEVERAL MONO OR STEREO FILES USING A TIME-CHANGING BALANCE-FUNCTION
# 
# USAGE: submix faders inf1 inf2 [inf3..] outf balance-data envelope-data
# 
# BALANCE-DATA  is a list of value sets.
#               Each consisting of a time, followed by the
#               RELATIVE level of each file in the mix, at that time.
# 
#               Whatever set of numbers is used, THESE ARE SCALED
#               so the total set of levels used ON ANY LINE adds up to 1.0
#               (This means that if all signals are at max level
#               the output will never exceed max level)
# 
#               You can't use this data to vary the OVERALL level.
#               and, in particular, the values cannot ALL be zero.
# 
# ENVELOPE-DATA is the loudness envelope to apply to the TOTAL sound.
#               and this (also) can vary over time.
# 
# 
cdp.submix.add_process("faders", "sndfiles", "sndfiles", None, "Mix several soundfiles using a time-changing level-balance function.")
params = []
cdp.submix.faders.add_parameters(params)
#
# SUBMIX FILEFORMAT
#
# CDP Release 5 2005
# MIXFILES CONSIST OF LINES WITH ONE OF THE FOLLOWING FORMATS
# sndname starttime_in_mix  chans  level
# sndname starttime_in_mix  1      level       pan
# sndname starttime_in_mix  2      left_level  left_pan  right_level  right_pan
# 
# SNDNAME is name of a MONO or STEREO sndfile: ALL MUST BE OF SAME SAMPLING RATE.
# CHANS   is number of channels in this soundfile (1 or 2 ONLY)
# LEVEL   is loudness, as number (1 = unity gain) or dB (0dB = unity gain)
#         Mono AND stereo files MAY have a SINGLE level parameter (NO pan data).
#         In this case, MONO files in STEREO mixes are panned centrally.
#         OTHERWISE....
#         MONO files   must have 1 level & 1 pan parameter (ONLY).
#         STEREO files MUST have 2 level & 2 pan params, 1 for each channel.
# PAN     is spatial positioning of file (or file channel) in output mix.
#         -1 HArd Left : 0 Centre : 1 Hard Right
#         < -1 hard left & attenuated : > 1 hard right & attenuated.
# ALSO....
# 1) The mixfile list need NOT be in starttime order.
# 2) Silence at start of mix IGNORED.(splice on afterwards if needed).
# 3) With exclusively mono inputs, with NO pan information, OR 
#    when ALL panned hard left, or ALL hard right, output is MONO.
#    All other situations produce stereo output.
# 4) TAKE CARE WHEN PANNING BOTH CHANNELS OF A STEREO FILE.
#    The channel contributions sum, so e.g. if both channels are
#    panned to same position without attenuation, overload possible.
# 5) You may test for maximum level in your mix output with submix GETLEVEL.
#    Reduce the mixfile level, if necessary, using 'submix attenuate'.
# 6) You may put comment lines in mixfiles : Start such line with a ';'
#    Blank lines are ignored.
# 
# 
cdp.submix.add_process("fileformat", "mixfile", "mixfile", None, "Displays format of mixfiles.")
params = []
cdp.submix.fileformat.add_parameters(params)
#
# SUBMIX GETLEVEL
#
# CDP Release 5 2005
#   TEST THE MAXIMUM LEVEL OF A MIX, DEFINED IN A MIXFILE
# AND SUGGEST A GAIN FACTOR TO AVOID OVERLOAD, IF NECESSARY
# 
# USAGE: submix getlevel 1   mixfile             [-sSTART] [-eEND]
# USAGE: submix getlevel 2-3 mixfile outtextfile [-sSTART] [-eEND]
# 
# MODES...
# 1) finds maximum level of mix.
# 2) finds locations of clipping in mix.
# 3) finds locations of clipping, and maxlevel, in mix.
# START gives starttime START (to start mixing later than zero).
# END   gives output endtime END (to stop mix before its true end).
# OUTTEXTFILE  stores clipping locations (& maxlevel, in mode 3).
# 
# You can alter the overall level of a mix with 'submix attenuate'.
# 
# 
cdp.submix.add_process("getlevel", "mixfile", "mixfile", 3, "Test maximum level of a mix, defined in a mixfile.")
params = []
cdp.submix.getlevel.add_mode(1, params, "MAXIMUM LEVEL")
params = []
cdp.submix.getlevel.add_mode(2, params, "CLIPPING TIMES")
params = []
cdp.submix.getlevel.add_mode(3, params, "MAXLEVEL & CLIPTIMES")
#
# SUBMIX INBETWEEN
#
# CDP Release 5 2005
# GENERATE A SET OF SOUNDS IN-BETWEEN THE 2 INPUT SOUNDS
#       THROUGH WEIGHTED MIXES OF THE INPUT SOUNDS,
#          FROM MOSTLY SOUND1 TO MOSTLY SOUND2.
# 
# USAGE: submix inbetween 1 infile1  infile2  outname  count
# OR:    submix inbetween 2 infile1  infile2  outname  ratios
# 
# OUTNAME  is your GENERIC name for the output sndfiles.
#          New soundfiles will be called outname001 outname002 etc
# 
# COUNT    If a single number (COUNT) is given to the program,
#          it generates amplitude ratios for the new sounds, automatically,
#          and COUNT is the number of inbetween outfiles to produce.
# 
# RATIOS   A ratio, or a list of ratios in a textfile. These are
#          the level of file2 RELATIVE to file 1,for each new outfile,
#          as FRACTIONS (Range 0-1)
#          There must be an even number of values and in ascending order.
# 
# Ensure NONE of the files to be created already exists!!
# 
# 
cdp.submix.add_process("inbetween", "sndfile", "sndfile", 2, "Generate set of sounds in-between 2 input sounds (same no. of channels).")
params = []
cdp.submix.inbetween.add_mode(1, params, "AUTOMATIC")
params = []
cdp.submix.inbetween.add_mode(2, params, "GIVE MIX RATIOS")
#
# SUBMIX INBETWEEN2
#
# CDP Release 5 2005
# GENERATE A SET OF SOUNDS IN-BETWEEN THE 2 INPUT SOUNDS
#       THROUGH INTERPOLATION PEGGED TO ZERO_CROSSINGS.
# 
# USAGE: submix inbetween2 infile1  infile2  outname  count  cutoff
# OUTNAME  is your GENERIC name for the output sndfiles.
#          New soundfiles will be called outname001 outname002 etc
# 
# COUNT    is the number of inbetween outfiles to produce.
# 
# CUTOFF   Is the frquency above which 'cycles' are ignored: 
#          usually noise, they are incorporated into other cycles.
# 
# Ensure NONE of the files to be created already exists!!
# 
# 
cdp.submix.add_process("inbetween2", "sndfile", "sndfile", None, "Generate set of sounds in-between 2 input sounds (same no. of channels), through interpolation pegged to zero-crossings.")
params = []
cdp.submix.inbetween2.add_parameters(params)
#
# SUBMIX INTERLEAVE
#
# CDP Release 5 2005
# INTERLEAVE MONO FILES TO MAKE MULTICHANNEL OUTFILE.
# 
# USAGE: submix interleave sndfile1 sndfile2 [sndfile3 sndfile4] outfile
# 
# MAx number of channels in output is 4
# First sndfile goes to left channel of stereo, (or channel 1 of 4), etc.
# 
# 
cdp.submix.add_process("interleave", "sndfile", "sndfile", None, "Interleave mono files to make multi-channel outfile.")
params = []
cdp.submix.interleave.add_parameters(params)
#
# SUBMIX MERGE
#
# CDP Release 5 2005
# QUICK MIX OF 2 SNDFILES (Mono or Stereo only).
# 
# USAGE: submix merge sndfile1 sndfile2 outfile
#           [-sstagger] [-jskip] [-kskew] [-bstart] [-eend]
# 
# STAGGER ...2nd file enters, 'stagger' secs after first.
# SKIP ......skip by 'skip' secs into the 2nd file, before starting to mix.
# SKEW.......1st sound has 'skew' times more gain than 2nd.
# START .....Start the mix at the time specified.
# END........Stop the mix at the time specified.
# Stagger and Skip are approximated to within about one hundredth of a second.
# 
# 
cdp.submix.add_process("merge", "sndfile", "sndfile", None, "Quick mix of two soundfiles (with same number of channels).")
params = []
cdp.submix.merge.add_parameters(params)
#
# SUBMIX MERGEMANY
#
# CDP Release 5 2005
# QUICK MIX OF SEVERAL SNDFILES (WITH SAME NUMBER OF CHANNELS).
# 
# USAGE: submix mergemany sndfile1 sndfile2 [sndfile3 ....] outfile
# 
# 
cdp.submix.add_process("mergemany", "sndfiles", "sndfiles", None, "Quick mix of several soundfiles (with the same number of channels).")
params = []
cdp.submix.mergemany.add_parameters(params)
#
# SUBMIX MIX
#
# CDP Release 5 2005
# MIX SOUNDS AS INSTRUCTED IN A MIXFILE
# 
# USAGE:	submix mix mixfile outsndfile [-sSTART] [-eEND] [-gATTENUATION] [-a]
# 
# START       gives starttime START (to start mixing later than zero).
# END         gives output endtime END (to stop mix before its true end).
# ATTENUATION reduces level of entire mix (range >0-1).
# 
# Note that the START and END params are intended for mix TESTING purposes only.
# If you want to keep output from such a testmix, you should TOPNTAIL it.
# 
# -a    alternative mix algorithm, slightly slower,
#       but may avoid clipping in special circumstances.
# 
# 
cdp.submix.add_process("mix", "mixfile", "mixfile", None, "Mix sounds as instructed in a mixfile.")
params = []
cdp.submix.mix.add_parameters(params)
#
# SUBMIX MODEL
#
# CDP Release 5 2005
# REPLACE SOUNDFILES IN EXISTING MIXFILE.
# 
# USAGE: submix model mixfile sndfile1 [sndfile2 ........] outfile
# 
# 
cdp.submix.add_process("model", "mixfile", "mixfile", None, "Replace soundfiles in an existing mixgfile.")
params = []
cdp.submix.model.add_parameters(params)
#
# SUBMIX ONGRID
#
# CDP Release 5 2005
# CONVERT LISTED SNDFILES TO BASIC MIXFILE ON TIMED GRID (FOR EDITING)
# 
# USAGE: submix ongrid infil1 infil2 [infil3..] outmixfile gridfile
# 
# GRIDFILE a list of times (one for each input sound) of sounds in mix
#          OR a list with some times preceded by 'x' (no space after 'x')
#          where 'x' marks a time to actually use 
#          (other grid times being ignored).
# 
# Numbers, or gridpoint names, may follow times (on same line ONLY)
# 
# IF NO SOUND USED AT TIME ZERO, mix will skip to first snd actually used.
# To avoid this, use a SILENT FILE at time zero.
# 
# 
cdp.submix.add_process("ongrid", "sndfile", "sndfile", None, "Convert listed soundfiles to a basic mixfile on timed grid (for editing).")
params = []
cdp.submix.ongrid.add_parameters(params)
#
# SUBMIX PAN
#
# CDP Release 5 2005
# PAN A MIXFILE.
# 
# USAGE: submix pan inmixfile outmixfile pan
# 
# PAN may vary over time
#     in this case, soundfiles in mix are POSITIONED differently
#     depending on time they begin, and value in PAN file at that time.
#     BUT the sounds THEMSELVES will not be panned (in the final mixdown)
# 
# 
cdp.submix.add_process("pan", "sndfile", "sndfile", None, "Pan a mixfile.")
params = []
cdp.submix.pan.add_parameters(params)
#
# SUBMIX SHUFFLE
#
# CDP Release 5 2005
# SHUFFLE THE DATA IN A MIXFILE
# 
# USAGE: submix shuffle 1-6 inmixfile outmixfile         [-sstartl] [-eendl]
# OR:    submix shuffle 7   inmixfile outmixfile newname [-sstartl] [-eendl] [-x]
# 
# STARTL: line at which shuffling begins (default: 1st in file)
# ENDL  : line at which shuffling ends  (default: last in file).
# MODES ARE....
# 1)  DUPLICATE EACH LINE.
# 2)  REVERSE ORDER OF FILENAMES.
# 3)  SCATTER ORDER OF FILENAMES.
# 4)  REPLACE SOUNDS IN SELECTED LINES WITH SOUND IN STARTLINE.
# 5)  OMIT LINES           (closing up timegaps appropriately)
# 6)  OMIT ALTERNATE LINES (closing up timegaps appropriately)
#                          In modes 5 & 6 mix must be in correct time-order.
#                          mixfiles can be time-ordered using timewarp mode 1
# 7)  DUPLICATE AND RENAME: duplicate each line with new sound, newname.
# 
#                          Program checks 'newname' is compatible sndfile, BUT,
# -x  flag TURNS OFF 'newname' checking in mode 7.
# 
# 
cdp.submix.add_process("shuffle", "mixfile", "mixfile", 7, "Shuffle the data in a mixfile.")
params = []
cdp.submix.shuffle.add_mode(1, params, "DUPLICATE LIN")
params = []
cdp.submix.shuffle.add_mode(2, params, "REVERSE ORDER FILENAMES")
params = []
cdp.submix.shuffle.add_mode(3, params, "SCATTER ORDER FILENAMES")
params = []
cdp.submix.shuffle.add_mode(4, params, "FIRST FILENAME TO ALL")
params = []
cdp.submix.shuffle.add_mode(5, params, "OMIT LINES")
params = []
cdp.submix.shuffle.add_mode(6, params, "OMIT ALTERNATE LINES")
params = []
cdp.submix.shuffle.add_mode(7, params, "DUPL LINES, NEW FILENAME")
#
# SUBMIX SPACEWARP
#
# CDP Release 5 2005
# ALTER THE SPATIAL DISTRIBUTION OF A MIXFILE.
# 
# USAGE: submix spacewarp 1-2 inmixfile outmixfile Q     [-sstartl] [-eendl]
# OR:    submix spacewarp 4-6 inmixfile outmixfile Q1 Q2 [-sstartl] [-eendl]
# OR:    submix spacewarp 7   inmixfile outmixfile
# OR:    submix spacewarp 8   inmixfile outmixfile Q
# STARTL: line at which warping begins (default: 1st in file)
# ENDL  : line at which warping ends  (default: last in file).
# MODES ARE....
# 1) SOUNDS TO SAME POSITION           Q is position. (stereo files become mono)
# 2) NARROW SPATIAL SPREAD             Q is a +ve number < 1.0
# 3) SEQUENCE POSITIONS LEFTWARDS    over range Q1-Q2 (stereo files become mono)
# 4) SEQUENCE POSITIONS RIGHTWARDS   over range Q1-Q2 (stereo files become mono)
# 5) RANDOM-SCATTER POSITIONS      within range Q1-Q2 (stereo files become mono)
# 6) RANDOM, BUT ALTERNATE TO L/R OF THE CENTRE OF THE SPATIAL RANGE SPECIFIED.
#                                         range Q1-Q2 (stereo files become mono)
# 7) INVERT STEREO IN ALTERNATE LINES OF MIXFILE: (Use to avoid clipping).
# 8) INVERT STEREO IN SPECIFIED LINE OF MIXFILE   Q is line number.
# 
# 
cdp.submix.add_process("spacewarp", "mixfile", "mixfile", 8, "Alter spatial distribution of a mixfile.")
params = []
cdp.submix.spacewarp.add_mode(1, params, "FIX POSITION")
params = []
cdp.submix.spacewarp.add_mode(2, params, "NARROW")
params = []
cdp.submix.spacewarp.add_mode(3, params, "SEQUENCE LEFTWARDS")
params = []
cdp.submix.spacewarp.add_mode(4, params, "SEQUENCE RIGHTWARDS")
params = []
cdp.submix.spacewarp.add_mode(5, params, "SCATTER")
params = []
cdp.submix.spacewarp.add_mode(6, params, "SCATTER ALTERNATING")
params = []
cdp.submix.spacewarp.add_mode(7, params, "TWIST WHOLE MIX")
params = []
cdp.submix.spacewarp.add_mode(8, params, "TWIST A LINE")
#
# SUBMIX SYNC
#
# CDP Release 5 2005
# SYNCHRONISE SOUNDFILES IN A MIXFILE,
# OR GENERATE SUCH A MIXFILE FROM A LIST OF SNDFILES.
# 
# USAGE: submix sync mode intextfile outmixfile
# 
# INTEXTFILE is list of sndfiles OR an existing mixfile.
# 
# MODES ARE....
# 1) SYNC SNDFILE MIDTIMES.
# 2) SYNC SNDFILE ENDTIMES.
# 
# 
cdp.submix.add_process("sync", "mixfile", "mixfile", 2, "Synchronise sounds, into a mixfile (you reset levels).")
params = []
cdp.submix.sync.add_mode(1, params, "AT MIDTIMES")
params = []
cdp.submix.sync.add_mode(2, params, "AT ENDTIMES")
#
# SUBMIX SYNCATTACK
#
# CDP Release 5 2005
# SYNCHRONISE ATTACKS OF SOUNDFILES, IN A MIXFILE,
# OR GENERATE SUCH A MIXFILE FROM A LIST OF SNDFILES.
# 
# USAGE: submix syncattack intextfile outmixfile  [-wdiv] [-p]
# 
# INTEXTFILE is a list of sndfiles OR an existing mixfile.
#            with a sndfilelist (only), each sndname MAY be followed by 2 times,
#            which limit the search area for the sound's attack.
# -w         DIV is factor shortening window which scans for the attack.
#            It can be 2,4,8,16, or 32 ONLY.
# -p         Program finds peak-power segment, before locating its max sample.
#            Default: program looks purely for maxsample.
# 
# The program estimates output levels required to prevent clipping,
# But estimate may be over-cautiously low: adjust with 'submix attenuate'.
# 
# 
cdp.submix.add_process("syncattack", "mixfile", "mixfile", None, "Synchronise sound attacks, into a mixfile (ditto).")
params = []
cdp.submix.syncattack.add_parameters(params)
#
# SUBMIX TEST
#
# CDP Release 5 2005
# TEST THE SYNTAX OF A MIXFILE
# 
# USAGE:	submix test mixfile
# 
# 
# 
cdp.submix.add_process("test", "mixfile", "mixfile", None, "Test the syntax of a mixfile.")
params = []
cdp.submix.test.add_parameters(params)
#
# SUBMIX TIMEWARP
#
# CDP Release 5 2005
# TIMEWARP THE DATA IN A MIXFILE
# 
# USAGE:  submix timewarp 1    inmixfile outmixfile
# OR:     submix timewarp 2-5  inmixfile outmixfile   [-sstartline] [-eendline]
# OR:     submix timewarp 6-16 inmixfile outmixfile Q [-sstartline] [-eendline]
# 
# STARTLINE: line at which warping begins (default: 1st in file)
# ENDLINE  : line at which warping ends  (default: last in file).
# MODES ARE....
# 1)  SORT INTO TIME ORDER.
# 2)  REVERSE TIMING PATTERN:  e.g. rit. of sound entries becomes an accel.
# 3)  REVERSE TIMING PATTERN & ORDER OF FILENAMES.
# 4)  FREEZE TIMEGAPS          between sounds, at FIRST timegap value.
# 5)  FREEZE TIMEGAPS & NAMES  ditto, and all files take firstfile name.
# 6)  SCATTER ENTRY TIMES      about orig vals. Q is scattering: Range(0-1).
# 7)  SHUFFLE UP ENTRY TIMES   shuffle times in file forward by time Q secs.
# 8)  ADD TO TIMEGAPS          add fixed val Q secs, to timegaps between sounds.
# 9)  CREATE FIXED TIMEGAPS 1  between all sounds,timegap = Q secs
# 10) CREATE FIXED TIMEGAPS 2  startval+Q,startval+2Q  etc
# 11) CREATE FIXED TIMEGAPS 3  startval*Q startval*2Q etc
# 12) CREATE FIXED TIMEGAPS 4  startval*Q     startval*Q*Q    etc
# 13) ENLARGE TIMEGAPS 1       multiply them by Q.
# 14) ENLARGE TIMEGAPS 2       by +Q, +2Q,+3Q  etc
# 15) ENLARGE TIMEGAPS 3       by *Q *2Q *3Q
# 16) ENLARGE TIMEGAPS 4       by *Q, *Q*Q, *Q*Q*Q  etc. (CARE!!)
# 
# 
# 
cdp.submix.add_process("timewarp", "mixfile", "mixfile", 16, "Timewarp the data in a mixfile.")
params = []
cdp.submix.timewarp.add_mode(1, params, "SORT ENTRY TIMES")
params = []
cdp.submix.timewarp.add_mode(2, params, "REVERSE TIMING PATTERN")
params = []
cdp.submix.timewarp.add_mode(3, params, "REVERSE TIMING & NAMES")
params = []
cdp.submix.timewarp.add_mode(4, params, "FREEZE TIMEGAPS")
params = []
cdp.submix.timewarp.add_mode(5, params, "FREEZE TIMEGAPS & NAMES")
params = []
cdp.submix.timewarp.add_mode(6, params, "SCATTER ENTRY TIMES")
params = []
cdp.submix.timewarp.add_mode(7, params, "SHUFFLE UP ENTRY TIMES")
params = []
cdp.submix.timewarp.add_mode(8, params, "ADD TO TIMEGAPS")
params = []
cdp.submix.timewarp.add_mode(9, params, "CREATE TIMEGAP 1")
params = []
cdp.submix.timewarp.add_mode(10, params, "CREATE TIMEGAP 2")
params = []
cdp.submix.timewarp.add_mode(11, params, "CREATE TIMEGAP 3")
params = []
cdp.submix.timewarp.add_mode(12, params, "CREATE TIMEGAP 4")
params = []
cdp.submix.timewarp.add_mode(13, params, "ENLARGE TIMEGAP 1")
params = []
cdp.submix.timewarp.add_mode(14, params, "ENLARGE TIMEGAP 2")
params = []
cdp.submix.timewarp.add_mode(15, params, "ENLARGE TIMEGAP 3")
params = []
cdp.submix.timewarp.add_mode(16, params, "ENLARGE TIMEGAP 4")
#
# SYNTH
#
#
# SYNTH CHORD
#
# CDP Release 5 2005
# GENERATE CHORD ON SIMPLE WAVEFORM
# 
# USAGE: synth wave mode datafile outfile sr chans dur  [-aamp] [-ttabsize]
# 
# MODES ARE
# 1) DATAFILE has list of midi data
# 2) DATAFILE has list of frequency data
# SR      (sample rate) can be 48000, 24000, 44100, 22050, 32000, or 16000
# CHANS   can be 1, 2 or 4
# DUR     is duration of output snd, in seconds.
# AMP     is amplitude of output sound: 0.0 < Range <= 1.0 (max & default).
# TABSIZE is size of table storing waveform.
#         defaults to 4096: input value always rounded to multiple of 4.
# 
# 
# 
cdp.synth.add_process("chord", "textfile", "textfile", None, "Generate a chord with a simple waveform.")
params = []
cdp.synth.chord.add_parameters(params)
#
# SYNTH CLICKS
#
# CDP Release 5 2005
# CLICKTRACK    USAGE: synth clicks mode outname clickfile [-sstart -eend -zzero]
# 
#       make clicktrack from 'start' to 'end'; music starting at dataline 'zero'.
#       MODE 1: start and end are TIMES:    MODE 2: start & end are data linenos.
#     CLICKFILE contains sequence of datalines. Each dataline has a line number 
#     followed by 2, 3 or 4 data items, separated by spaces, which can be....
# TIME  141.52   (Set time to 141.52 secs: must be later than previous event)
# GP  1  23.7    (Pause of 23.7sec, with accent [1] at start: '0' for no accent)
#        OR the following set of items:-
# 1) TEMPO : in one of the forms (with no spaces around '='):-
#        1=144         (crotchet = 144)   1.5=100    (dotted crotchet = 100)
#        0.5=144to85.3 (tempo change from quaver = 144 to 85.3)
# 2) BARRING :  in the form 4:4 or 6:8 or 7:16 etc. (no spaces around the ':')
# 3) COUNT :  i.e. the (integer) number of bars in this format.
# ------- and, optionally ---------
# 4) ACCENT PATTERN  1.....  strong beat followed by 5 weak beats
#                    1..1..  strong beat (start), secondary (at 4), weak between
#                    100100  strong & secondary beats, but NO intermediate beats
# IF THE ACCENT PATTERN IS OMITTED, default patterns are used. These are:-
# An accent on the start of each bar PLUS
# a) in 6:8, 9:8, 12:8, 15:8 etc, or 6:4, 6:16, 6:32, 9:4, 9:16 etc.
#       sound on every unit (4,8,16,32 etc.), secondary accents every 3rd beat
# b) in All other meters: NO secondary accents
# 
# 
cdp.synth.add_process("clicks", "textfile", "textfile", 2, "Create a click track from tempo, meter & barring data.")
params = []
cdp.synth.clicks.add_mode(1, params, "START & END ARE TIMES")
params = []
cdp.synth.clicks.add_mode(2, params, "START & END ARE DATA LINE Nos.")
#
# SYNTH NOISE
#
# CDP Release 5 2005
# GENERATE NOISE
# 
# USAGE: synth noise outfile sr chans dur [-aamp]
# 
# SR      (sample rate) can be 48000, 24000, 44100, 22050, 32000, or 16000
# CHANS   can be 1, 2 or 4
# DUR     is duration of output snd, in seconds.
# AMP     is amplitude of output sound: 0.0 < Range <= 1.0 (max & default).
# 
# Amp may vary through time.
# 
# 
cdp.synth.add_process("noise", "none", "none", None, "Make soundfiles of noise.")
params = []
cdp.synth.noise.add_parameters(params)
#
# SYNTH SILENCE
#
# CDP Release 5 2005
# MAKE SILENT SOUNDFILE
# 
# USAGE: synth silence outfile sr chans dur
# 
# SR      (sample rate) can be 48000, 24000, 44100, 22050, 32000, or 16000
# CHANS   can be 1, 2 or 4
# DUR     is duration of output snd, in seconds.
# 
# 
cdp.synth.add_process("silence", "none", "none", None, "Make soundfiles of silence.")
params = []
cdp.synth.silence.add_parameters(params)
#
# SYNTH SPECTRA
#
# CDP Release 5 2005
# GENERATE BOTH CHANNELS OF A STEREO SPECTRAL BAND
# 
# USAGE: synth spectra outfilename dur frq spread max-foc min-foc
#                      timevar srate [-p]
# 
# DUR      duration of output snd, in seconds.
# FRQ      centre frequency of the band.
# SPREAD   width of band, in Hz (default) or as transposition ratio.
# 'Foc' = focus, degree to which band energy is concentrated at centre frequency.
# MAX-FOC  range 0 1
# MIN-FOC  range 0 1
# TIMEVAR  Degree to which the band varies over time. Range 0-1.
# SRATE    Sample rate of output audio file.
# 
# -p       If flag set, 'SPREAD' is a transposition ratio.
# 
# Outputs files 'outfilename0' and 'outfilename1'
# 
# 
cdp.synth.add_process("spectra", "none", "none", None, "Generate both channels of a stereo spectral band.")
params = []
cdp.synth.spectra.add_parameters(params)
#
# SYNTH WAVE
#
# CDP Release 5 2005
# GENERATE SIMPLE WAVEFORMS
# 
# USAGE: synth wave mode outfile sr chans dur freq [-aamp] [-ttabsize]
# 
# MODES ARE
# 1) sine wave
# 2) square wave
# 3) sawtooth wave
# 4) ramp wave
# 
# SR      (sample rate) can be 48000, 24000, 44100, 22050, 32000, or 16000
# CHANS   can be 1, 2 or 4
# DUR     is duration of output snd, in seconds.
# FREQ    is frq of output sond, in Hz
# AMP     is amplitude of output sound: 0.0 < Range <= 1.0 (max & default).
# TABSIZE is size of table storing waveform.
#         defaults to 256: input value always rounded to multiple of 4.
# 
# Frq and Amp may vary through time.
# 
# 
cdp.synth.add_process("wave", "none", "none", 4, "Generate synthetic waveforms.")
params = []
cdp.synth.wave.add_mode(1, params, "SINE")
params = []
cdp.synth.wave.add_mode(2, params, "SQUARE")
params = []
cdp.synth.wave.add_mode(3, params, "SAW")
params = []
cdp.synth.wave.add_mode(4, params, "RAMP")
#
# PVOC
#
#
# PVOC ANAL
#
# CDP Release 5 2005
# CONVERT SOUNDFILE TO SPECTRAL FILE
# 
# USAGE: pvoc anal  mode infile outfile [-cpoints] [-ooverlap]
# 
# MODES ARE....
# 1) STANDARD ANALYSIS
# 2) OUTPUT SPECTRAL ENVELOPE VALS ONLY
# 3) OUTPUT SPECTRAL MAGNITUDE VALS ONLY
# POINTS   No of analysis points (2-32768 (power of 2)): default 1024
#          More points give better freq resolution
#          but worse time-resolution (e.g. rapidly changing spectrum).
# OVERLAP  Filter overlap factor (1-4): default 3
# 
# 
cdp.pvoc.add_process("anal", "sndfile", "analfile", 3, "Convert soundfile to spectral file.")
params = [
        ["-c", 2, 32768, "No of analysis points (2-32768 (power of 2)): default 1024. More points give better freq resolution."],
        ["-o", 1, 4, "Filter overlap factor (1-4): default 3"]
        ]
cdp.pvoc.anal.add_mode(1, params, "STANDARD")
cdp.pvoc.anal.add_mode(2, params, "GET SPEC ENVELOPE ONLY")
cdp.pvoc.anal.add_mode(3, params, "GET SPEC MAGNITUDES ONLY")
#
# PVOC SYNTH
#
# CDP Release 5 2005
# CONVERT SPECTRAL FILE TO SOUNDFILE
# 
# USAGE: pvoc synth infile outfile
# 
# 
cdp.pvoc.add_process("synth", "analfile", "sndfile", None, "Convert spectral file to soundfile.")
params = []
cdp.pvoc.synth.add_parameters(params)
#
# PITCHINFO
#
#
# PITCHINFO CONVERT
#
# CDP Release 5 2005
# pitchinfo convert pitchfile outtextfile [-dI]
# 
# CONVERT A BINARY PITCH-DATAFILE TO A TIME/FRQ BRKPNT TEXTFILE.
# 
# -d  I = acceptable pitch error in brkpntfile data-reduction. (semitones)
#     (Range > 0.0 : Default = eighth_tone = 0.250000)
# 
# 
cdp.pitchinfo.add_process("convert", "pitchfile", "pitchfile", None, "Convert binary pitchfile to time/frequency breakpoint textfile.")
params = []
cdp.pitchinfo.convert.add_parameters(params)
#
# PITCHINFO HEAR
#
# CDP Release 5 2005
# pitchinfo hear pitchfile outfile [-ggain]
# 
# CONVERT BINARY PITCHFILE TO ANALYSIS TESTTONE FILE.
#            (RESYNTHESISE TO HEAR PITCH).
# 
# -g  gain > 0.0 (default: 1.0)
# 
# 
cdp.pitchinfo.add_process("hear", "pitchfile", "pitchfile", None, "Convert binary pitchfile to analysis testtone file.")
params = []
cdp.pitchinfo.hear.add_parameters(params)
#
# PITCHINFO INFO
#
# CDP Release 5 2005
# pitchinfo info pitchfile
# 
# DISPLAY INFORMATION ABOUT PITCHDATA IN PITCHFILE.
# 
# Finds mean pitch, max and min pitch (with timings), as Hz and MIDI.
# Also displays total range, in octaves and semitones.
# 
# 
cdp.pitchinfo.add_process("info", "pitchfile", "pitchfile", None, "Display information about pitchdata in binary pitchfile.")
params = []
cdp.pitchinfo.info.add_parameters(params)
#
# PITCHINFO SEE
#
# CDP Release 5 2005
# pitchinfo see 1 pitchfile    outsndfile scalefact
# pitchinfo see 2 transposfile outsndfile
# 
# CONVERT BINARY PITCHFILE OR TRANSPOSITION-FILE TO PSEUDO-SNDFILE, FOR VIEWING.
# 
# MODES....
# (1) PITCHFILE is a binary pitchdata file.
#     SCALEFACT (> 0.0) multiplies pitch vals, for ease of viewing.
#     Pitch data scaled by (e.g.) 100 can be read directly from 'sndfile'
#     (Remembering to divide numeric values by 100).
# 
# (2) TRANSPOSFILE is a binary transposition-data file.
#     Transposition data is automatically scaled to half max range,
#     And displayed in log format (0 = no transposition, + = up, - = down),
#     giving a schematic idea ONLY, of transposition data.
# 
# 
cdp.pitchinfo.add_process("see", "pitchfile", "pitchfile", 2, "Convert pitch (or transpos) file to 'soundfile' to view.")
params = []
cdp.pitchinfo.see.add_mode(1, params, "SEE PITCH")
params = []
cdp.pitchinfo.see.add_mode(2, params, "SEE TRANSPOSITION")
#
# PITCHINFO ZEROS
#
# CDP Release 5 2005
# pitchinfo zeros pitchfile
# 
# SHOWS WHETHER PITCHFILE CONTAINS UNINTERPOLATED ZEROS (UNPITCHED WINDOWS).
# 
# 
cdp.pitchinfo.add_process("zeros", "pitchfile", "pitchfile", None, "Does binary pitchfile contains zeros (unpitched windows)?")
params = []
cdp.pitchinfo.zeros.add_parameters(params)
#
# SPEC
#
#
# SPEC BARE
#
# CDP Release 5 2005
# spec bare infile pitchfile outfile [-x]
# 
# ZERO THE DATA IN CHANNELS WHICH DO NOT CONTAIN HARMONICS
# 
# PITCHFILE must be extracted from your analysis file.
#           (normally using -z flag to mark any unpitched material).
# 
# -x        less body in resulting spectrum.
# 
# 
cdp.spec.add_process("bare", "analfile", "analfile", None, "Zero data in channels which don't contain harmonics.")
params = []
cdp.spec.bare.add_parameters(params)
#
# SPEC CLEAN
#
# CDP Release 5 2005
# spec clean 1-2 infile nfile       outfile skiptime [-gnoisgain]
# spec clean 3   infile nfile       outfile freq     [-gnoisgain]
# spec clean 4   infile nfile gfile outfile          [-gnoisgain]
# 
# REMOVE NOISE FROM PVOC ANALYSIS FILE.
# 
# INFILE,NFILE and GFILE are all pvoc analysis files.
# NFILE and GFILE should be cut (spec cut) from INFILE
# to show typical noise (NFILE) and good signal (GFILE).
# SKIPTIME     (seconds) may be set to time at which
#              good src. signal level has been established.
# NOISGAIN     multiplies noiselevels found in NFILE before they are used
#              for comparison with infile signal: (Default 2).
# MODES
# (1) deletes a channel (after skiptime) FROM THE TIME its level falls below
#     the (noisgain adjusted) maximum level seen for that channel in NFILE.
# (2) deletes channel (after skiptime) ANYWHERE its level falls below
#     the (noisgain adjusted) maximum level seen for that channel in NFILE.
# (3) Deletes channel as in MODE 2 but ONLY for channels of frq > FREQ.
# (4) deletes channel EVERYWHERE, whose level in GFILE is ALWAYS below
#     the (noisgain adjusted) maximum level seen for that channel in NFILE.
# 
# 
cdp.spec.add_process("clean", "analfile", "analfile", 4, "Remove noise from pvoc analysis file.")
params = []
cdp.spec.clean.add_mode(1, params, "FROM SPECIFIED TIME")
params = []
cdp.spec.clean.add_mode(2, params, "ANYWHERE")
params = []
cdp.spec.clean.add_mode(3, params, "ABOVE SPECIFIED FRQ")
params = []
cdp.spec.clean.add_mode(4, params, "BY COMPARISON METHOD")
#
# SPEC CUT
#
# CDP Release 5 2005
# spec cut infile outfile starttime endtime
# 
# CUT SECTION OUT OF ANALYSIS FILE, BETWEEN STARTTIME & ENDTIME (SECS)
# 
# 
# 
cdp.spec.add_process("cut", "analfile", "analfile", None, "Cut section out of analysis file.")
params = []
cdp.spec.cut.add_parameters(params)
#
# SPEC GAIN
#
# CDP Release 5 2005
# spec gain infile outfile gain
# 
# AMPLIFY OR ATTENUATE THE SPECTRUM
# 
# gain may vary over time.
# 
# 
# 
cdp.spec.add_process("gain", "analfile", "analfile", None, "Amplify or attenuate the spectrum.")
params = []
cdp.spec.gain.add_parameters(params)
#
# SPEC GATE
#
# CDP Release 5 2005
# spec gate infile outfile threshold
# 
# ELIMINATE CHANNEL DATA BELOW A THRESHOLD AMP
# 
# Threshold may vary over time. Range 0 to 1
# 
# 
cdp.spec.add_process("gate", "analfile", "analfile", None, "Eliminate channel data below a threshold amplitude.")
params = []
cdp.spec.gate.add_parameters(params)
#
# SPEC GRAB
#
# CDP Release 5 2005
# spec grab infile outfile time
# 
# GRAB A SINGLE ANALYSIS WINDOW AT 'TIME'
# 
# A time beyond end of file will grab last window in file.
# 
# 
# 
cdp.spec.add_process("grab", "analfile", "analfile", None, "Grab a single analysis window.")
params = []
cdp.spec.grab.add_parameters(params)
#
# SPEC MAGNIFY
#
# CDP Release 5 2005
# spec magnify infile outfile time dur
# 
# MAGNIFY A SINGLE ANALYSIS WINDOW, AT TIME 'TIME', TO DURATION 'DUR'.
# 
# 
# 
cdp.spec.add_process("magnify", "analfile", "analfile", None, "Magnify a single analysis window.")
params = []
cdp.spec.magnify.add_parameters(params)
#
# SPECINFO
#
#
# SPECINFO CHANNEL
#
# CDP Release 5 2005
# specinfo channel infile frq
# 
# RETURNS PVOC CHANNEL NUMBER CORRESPONDING TO FREQUENCY GIVEN.
# 
# 
cdp.specinfo.add_process("channel", "analfile", "analfile", None, "Get channel number corresponding to frequency given.")
params = []
cdp.specinfo.channel.add_parameters(params)
#
# SPECINFO FREQUENCY
#
# CDP Release 5 2005
# specinfo frequency infile analysis_channel_number
# 
# RETURNS CENTRE FRQ OF PVOC CHANNEL SPECIFIED.
# 
# 
cdp.specinfo.add_process("frequency", "analfile", "analfile", None, "Get centre frequency of channel specified.")
params = []
cdp.specinfo.frequency.add_parameters(params)
#
# SPECINFO LEVEL
#
# CDP Release 5 2005
# specinfo level infile outsndfile
# 
# CONVERT (VARYING) LEVEL OF ANALFILE TO PSEUDO-SNDFILE (1 WINDOW -> 1 SAMPLE)
# 
# View with a sndfile display program.
# 
# DO NOT ATTEMPT TO PLAY FILE!!.
# 
# 
cdp.specinfo.add_process("level", "analfile", "analfile", None, "Convert (varying) level of analysis file to 'soundfile' to view.")
params = []
cdp.specinfo.level.add_parameters(params)
#
# SPECINFO OCTVU
#
# CDP Release 5 2005
# specinfo octvu infile outtextfile time_step [-ffundamental]
# 
# DISPLAY TIMEVARYING AMPLITUDE OF SPECTRUM, WITHIN OCTAVE BANDS.
# 
# timestep is in MILLIsecs.
# Band-energy is totalled over each timestep duration.
# -f Octaves are centered on octave transpositions of fundamental.
# 
# The reported values are RELATIVE levels only
# and the lowest band includes all energy down to '0Hz'.
# 
# 
cdp.specinfo.add_process("octvu", "analfile", "analfile", None, "Display time-varying amp of spectrum, within octave bands.")
params = []
cdp.specinfo.octvu.add_parameters(params)
#
# SPECINFO PEAK
#
# CDP Release 5 2005
# specinfo peak infile outtextfile [-ccutoff_frq] [-ttimewindow] [-ffrqwindow] [-h]
# 
# LOCATE TIME-VARYING ENERGY CENTRE OF SPECTRUM.
# 
# CUTOFF_FRQ  above which spectral search begins
# TIMEWINDOW  for energy averaging: in SECONDS
# FRQWINDOW   for energy averaging: in SEMITONES
# -h          adjust result for sensitivity of ear.
# 
# OUTFILE is a text file of lines of data in form...
# 
# 	WINDOW starttime endtime : PEB lofrq TO hifrq'
# 
# (where 'PEB' means PEAK ENERGY BAND)
# 
# 
cdp.specinfo.add_process("peak", "analfile", "analfile", None, "Locate time-varying energy centre of spectrum.")
params = []
cdp.specinfo.peak.add_parameters(params)
#
# SPECINFO PRINT
#
# CDP Release 5 2005
# specinfo print(infile outtextfile time [-wwindowcnt])
# 
# PRINT DATA IN ANALYSIS FILE AS TEXT TO FILE.
# 
# TIME      in file at which printout begins.
# WINDOWCNT number of windows to print.
# OUTFILE   textfile to accept data.
# 
# WARNING:  using more than a few windows will generate a huge textfile.
# 
# 
#cdp.specinfo.add_process("print", "analfile", "analfile", None, "Print data in analysis file as textfile.")
#params = []
#cdp.specinfo.print.add_parameters(params)
#
# SPECINFO REPORT
#
# CDP Release 5 2005
# specinfo report mode infile outfile -fN|-pN [-i] pks [-bbt] [-ttp] [-sval]
# 
# REPORT ON LOCATION OF FREQUENCY PEAKS IN EVOLVING SPECTRUM,
# 
# OUTFILE is a textfile
# 
# MODES
# (1) Report on spectral peaks.
# (2) Report spectral peaks in loudness order.
# (3) Report spectral peaks as frq only (no time data).
# (4) Report spectral peaks in loudness order, as frq only (no time data).
# 
# -f   extract formant envelope linear frqwise,
#      using 1 point for every N equally-spaced frequency-channels.
# -p   extract formant envelope linear pitchwise,
#      using N equally-spaced pitch-bands per octave.
# -i   quicksearch for formants (less accurate).
# PKS  (max) number of peaks to find : Range 1 - 16
# -b   BT is bottom frequency to start peak search.
# -t   TP is top frequency to stop peak search.
# -s   VAL is number of windows over which peaks averaged.
#      Range 2 - 4097 : default 9 : WARNING: high values slow program!!
# 
# bottom frequency & top frequency may vary over time.
# 
# 
cdp.specinfo.add_process("report", "analfile", "analfile", 4, "Report location of frequency peaks in evolving spectrum.")
params = []
cdp.specinfo.report.add_mode(1, params, "ORDER BY FRQ & TIME")
params = []
cdp.specinfo.report.add_mode(2, params, "ORDER BY LOUDNESS & TIME")
params = []
cdp.specinfo.report.add_mode(3, params, "ORDER BY FRQ (UNTIMED)")
params = []
cdp.specinfo.report.add_mode(4, params, "ORDER BY LOUDNESS (UNTIMED)")
#
# SPECINFO WINDOWCNT
#
# CDP Release 5 2005
# specinfo windowcnt infile
# 
# RETURNS NUMBER OF ANALYSIS WINDOWS IN INFILE.
# 
# 
cdp.specinfo.add_process("windowcnt", "analfile", "analfile", None, "Get number of analysis windows in infile.")
params = []
cdp.specinfo.windowcnt.add_parameters(params)
